I am trying to get the selected radio button item in a radio button list using javascript. I am successful at doing this, but the problem is I have several Radio Button Lists, and the javascript gives me three alerts for each of them. In other words all three of them have at least one element checked and so I get three alerts with the below code.
Expand|Select|Wrap|Line Numbers
- var ips = document.getElementsByTagName('input');
- for(i=0; i<ips.length; i++)
- {
- if(ips[i].type == 'radio' && ips[i].checked)
- {
- a = ips[i].value;
- alert(a);
- }
- }
Thanks and Regards.