By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,521 Members | 1,222 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,521 IT Pros & Developers. It's quick & easy.

getting the selected radio button in a radio button list.

P: 45
`Hi all,

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
  1. var ips = document.getElementsByTagName('input');
  2. for(i=0; i<ips.length; i++)
  3. {
  4.     if(ips[i].type == 'radio' && ips[i].checked)
  5.     {           
  6.          a = ips[i].value;
  7.          alert(a);
  8.     }
  9. }
I want to get the selected item present in a asp:Table element having ID say....'xyz'. can anybody modify the code to give me the expected results.

Thanks and Regards.
Jun 14 '07 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
You could try
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('xyz').getElementsByTagName('input');
Jun 14 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.