Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: radio button.length when there is only single radio button?


Message #1 by "Aaron sahlin" <aaronsahlin@y...> on Thu, 31 Oct 2002 22:50:06
Hi, I have a dynamic list of radio button that the user can select from.  
To check to see which one is selected, I do the following.

   var radioObject = form.tableItem;
   var valID	   = null;

   // find which item is checked
   for (var i=0; i<radioObject.length; i++)
   {
     if(radioObject[i].checked)
     {
       valID = radioObject[i].id;
       break;
     }
   }

This works great, except when there is only one radio button....  Then 
radioObject.length is NULL!
How do I handle the case when there is only one radio button.  

Thanks in advance.

  Return to Index