here this is my code... here i am generating radio button dynamically using php code...
my problem is how to get which radio button selected on click of addForm() function...
<div class="modal-body"> <div> <input type="radio" name="form" value="Form-Name">Form-Name</div> <div> <input type="radio" name="form" value="Kalpit-Contact">Kalpit-Contact</div> <div> <input type="radio" name="form" value="Kalpit-Contact test">Kalpit-Contact test</div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-primary" onclick="addForm()">Add Page</button> </div>
Thanks in advance
We can check the status of a radio button by using the :checked jQuery selector together with the jQuery function is . For example: $('#el').is(':checked') . It is exactly the same method we use to check when a checkbox is checked using jQuery.
Use document. getElementById('id'). checked method to check whether the element with selected id is check or not. If it is checked then display its corresponding result otherwise check the next statement.
The checked selector is used to select all checked elements in input tag and radio buttons. This selector is used with radio buttons, checkbox and option elements. Example 1: html.
var selectedValue = $("input[name=form]:checked").val();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With