ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

How to get the index of a checked radio button?

user-image
تم إضافة السؤال من قبل Zaid Rabab'a , Software Development Team Leader , Al-Safa Co. Ltd.
تاريخ النشر: 2013/09/11
Muhammed Ajmal Seeraveetil
من قبل 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
من قبل 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
من قبل Feras Abualrub , Web Solutions Manager , Qistas for Information Technology

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

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....

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟