How to know
which radio button is selected from the group of Radio Buttons on button click using JQuery?
<input type="button" id="btnOrder" onclick="GetSelectedRadionButtonValue();"></input>
Example –
I will explain with the help of an example.
Following are the radio buttons tags
<input type="radio"
name="rdNew"
id="rdAll"
checked="checked"
value="0"
>All</input>
<input type="radio"
name="rdNew"
id="rdNew"
value="1">New</input>
<input type="radio" name="rdNew" id="rdInvoiced" value="3" >Invoiced</input>
<input type="radio"
name="rdNew"
id="rdCancelled"
value="4"
>Cancelled</input>
<input type="radio"
name="rdNew"
id="rdPartialInvoice"
value="5"
>Partial</input>
<input type="radio"
name="rdNew"
id="rdPaid"
value="6">Paid</input>
Input button Tag– On click we will get
the value of Selected Radio Button
JavaScript code for getting the selected
radio button value.
<script language="javascript" type="text/javascript">
function GetSelectedRadionButtonValue ()
{
var
selectedValue = $("input[@name=rdNew]:checked").val();
}
</script>
selectedValue is JavaScript
Variable which will return the value of
the selected radio button.
You can put
this code : $("input[@name=rdNew]:checked").val();
No comments:
Post a Comment