Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

How to get the index of a checked radio button?

user-image
Question ajoutée par Zaid Rabab'a , Software Development Team Leader , Al-Safa Co. Ltd.
Date de publication: 2013/09/11
Muhammed Ajmal Seeraveetil
par Muhammed Ajmal Seeraveetil , Software Engineer , Wipro

Please make clear in which language you need to get the indexed value  .Are you tring to get on the server side or cleint side ?

Thanks 

Ajmal

Ashraf Sabry
par Ashraf Sabry , Freelancer developer , N/A

I think you mean jQuery although you didn't clarify.

 

You can use this to get the zero based index:

$(":radio:checked").index()

You may combine it with any parent selectors. For example:

$("form :radio:checked").index()

$(".checkout :radio:checked").index()

$("#registerForm").find(":radio:checked").index()

 

References:

http://api.jquery.com/radio-selector/

http://api.jquery.com/checked-selector/

http://api.jquery.com/index/

Feras Abualrub
par Feras Abualrub , Web Solutions Manager , Qistas for Information Technology

var radioIndex = $(":radio[name='radioFieldName']").index($(":radio[name='radioFieldName']:checked"));

Utilisateur supprimé
par Utilisateur supprimé

Index!!!!!!

as I know Radio Btns (RB) are grouped...

so let's say you have3 RB, all of them should have the same  group, and each of them has a value and ID.

You check which one is checked and you get the value.

Or maybe am not getting your question correctly....

More Questions Like This