Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get value from RadioButtonList using jQuery?

I need to find out what is the selected value of RadioButtonList:

<div class="editor-field radio-button-list">
   <%= Html.RadioButtonListForEnum("Type", Model.Type)%>
</div>

I tried to use: $("#Type").find(":checked").val() but all I get is "undefined"... Any ideas?

like image 623
CodeName-2956981 Avatar asked Dec 09 '13 17:12

CodeName-2956981


People also ask

How to get radio button Text in jQuery?

$("input[name='Surv_Q"+i+"']:checked"). next('label'). text(); jquery.

How can I check if a Radiobutton is selected 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 do you check radio button is checked or not?

Using Input Radio checked property: The Input Radio checked property is used to return the checked status of an Input Radio Button. Use document. getElementById('id'). checked method to check whether the element with selected id is check or not.


2 Answers

I'm not sure the id of Type is coming out how you think it is. Or maybe Type is a duplicate Id. In any event, I think this is what you want

$(".editor-field.radio-button-list").find(":checked").val()
like image 152
Adam Rackis Avatar answered Sep 20 '22 23:09

Adam Rackis


It's working for server side control:

$("#<%=ControlID.ClientID%>").find(":checked").val();
like image 39
Sambath Kumar S Avatar answered Sep 19 '22 23:09

Sambath Kumar S