Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm making an application with PHP and javascript
There are 2 choices Yes and No.
When he chose NO option and submits, then going to the page "Thank You" and its data into the database. When selecting the YES option it will go to another page and its data into the database
<label class="radio inline"><input type="radio" name="choose" id="optionsRadios1" value="Yes">YES</label>
<label class="radio inline"><input type="radio" name="usia" id="optionsRadios2" value="No">NO</label>
<label class="control-label" for="">Nama</label>
<div class="controls"><input type="text" name="nama" ></div><input type="submit" name="submit" value="" class="btn next">
Try this,
function submitPage(url){
window.location.href=url;
}
$('input:radio').on('click',function(){
var url=this.value=='Yes' ? 'xyz.php' : 'abc.php';
submitPage(url); // or you can use ajax for post
});
Create a javascript function and fire it on the onclick event of the radiobutton passing the radio value in the parameter
And then in the function put condition for redirect and form submit
or you can call a ajax to insert data in the database
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Hi there i have a problem and dont know if there's a nice solution to do that.
<input type="checkbox" name="a" value="a">a<br>
<input type="checkbox" name="b" value="b">b<br>
<input type="checkbox" name="c" value="c">c<br>
<input type="checkbox" name="d" value="c">d<br>
<input type="checkbox" name="e" value="c">e<br>
I like to make it work more as a "range" so if a user click "a" and then "d" everything between that will be selected to.
I can make if statements with all the scenarios but maybe there's a better way to do that?
thanks
This is really simple with jQuery - use prevAll like so:
$('input[type="checkbox"]').on("change", function() {
if ($(this).is(":checked")) this.prevAll('input[type="checkbox"]').prop("checked", true);
});
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Photo of the website
I have a school project and I need to make a website where I can add more balance to my account. But I can't figure it out.
I would like to make an HTML number input and then that input needs to add up with my existing balance. But I can't make it work
This is the code I have:
<fieldset>
<legend>Opwaarderen</legend>
<input type="number" id="opwaarderen">
<input type="submit" onclick="opwaarderen()">
</fieldset
But how can I make the Javascript function? So that the input will add up to my already existing balance.
This will help
var currentCredit=0;
$("#a").click(()=>
{
alert(currentCredit+=Number($("#opwaarderen").val()));
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<fieldset>
<legend>Opwaarderen</legend>
<input type="number" id="opwaarderen">
<input type="submit" id="a">
</fieldset>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am looking to create a simple page using HTML and (probably) PHP or JQuery. The page should allow for multiple checkbox selection, and give a variable a value based on which boxes are checked. This can be on submit or can render live on the page.
i.e.
Checkbox 1
Checkbox 2
Checkbox 3
If checkbox 1 is checked, variable = X
If checkbox 1 & 2 are checked, variable = Y
If no checkboxes are checked, variable = Z
What is the best way to approach doing this?
The best way would be using Javascript (because it'd be done live) but if you are doing this with PHP. The form would be something like
<form action='phplogic.php' method='post>
<input type="checkbox" name="checkbox1" value="Yes" />
<input type="checkbox" name="checkbox2" value="Yes" />
<input type="checkbox" name="checkbox3" value="Yes" />
<input type="submit" name="formSubmit" value="Submit" />
</form>
phplogic would would look like this
<?php
if(isset($_POST[checkbox1']) && (isset($_POST['checkbox2'])) {
$variable = 'Y';
} else (isset($_POST[checkbox1'])) {
$variable = 'X';
} else {
$variable = 'Z';
}
Although this doesn't address if checkbox 2 alone is checked but you get the point. You can do something very similar with javascript. https://www.w3schools.com/jsref/prop_checkbox_value.asp
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
What are the different ways to disable a radio button.
I tried the example below but not working in my system with my environment set up. Its working if I am trying on notepad without environment. Is there any other ways?
var status = 'A';
$("input[type=radio][value=" + status + "]").attr("disabled",true);
I was able to just use disabled in HTML find your UPDATED CODE
<div id="cosProfile">CoS Profile</div>
<span class="icon-information"></span>
<div class="form-field" data-radio id="cosRadioBtns">
<span id="radio_prdefined"><input type="radio" name="CosProfile" data-radio
value="predefined" checked="checked" disabled/></span>
<label id="cos_predefined">Predefined Profile</label>
<span id="radio_custom"><input type="radio" name="CosProfile" data-radio
value="custom" disabled/></span>
<label id="cos_custom">Custom Profile</label>
</div>
Try this:
$("input[type=radio][value=" + status + "]").prop("disabled",true);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
So I am making this billing system where a user is able to configure a VPS. As seen in websites like Dell, the price of the server updates as you choose a specific option. I don't want the user to have to press a button "Refresh" every time they want to see the price of the new VPS. I have no idea how to do this, I tried to do some research and the only thing I found that was remotely close to this was things like Comet. I'm guessing that JavaScript should detect the change and change the overall price. Any suggestions/ideas?
Guess you wanna use JavaScript to achieve this.
<form action="">
<ul>
<li><label><input type="checkbox" value="1"> One</label></li>
<li><label><input type="checkbox" value="2"> Two</label></li>
<li><label><input type="checkbox" value="3"> Three</label></li>
<li><label><input type="checkbox" value="4"> Four</label></li>
<li><label><input type="checkbox" value="5"> Five</label></li>
</ul>
</form>
<p>Your total cost is <span>0</span> $.</p>
And a magic of JavaScript...
$(document).ready(function(){
$("input").click(function(){
val = 0;
$("input:checked").each(function(){
val += parseInt($(this).val());
});
$("span").text(val);
});
});
Fiddle: http://jsfiddle.net/praveenscience/q3XbZ/