Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know which radio button is selected in jquery? [duplicate]

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

like image 883
404 Not Found Avatar asked Dec 17 '13 07:12

404 Not Found


People also ask

How do you check whether a radio button is checked or not in jQuery?

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.

How can I know which radio button is selected via Javascript?

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.

Which selector is used to select radio which is selected?

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.


1 Answers

var selectedValue = $("input[name=form]:checked").val(); 
like image 192
Sarath Avatar answered Sep 27 '22 19:09

Sarath