Connecting Tech Pros Worldwide Forums | Help | Site Map

radio buttons

Member
 
Join Date: Feb 2007
Posts: 95
#1: Jan 6 '09
I have a simple question about radio buttons. I want the selection of one or the other (yes/no) to trigger a javascript function. How do I get the value of the radio buttons in javascript?

here's a couple things that don't work:
Expand|Select|Wrap|Line Numbers
  1. if (document.getElementById('isIdba[1]').value == "NO")
  2.  
  3. if(document.all.isIdba[2].value == "YES")
  4.  

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Jan 6 '09

re: radio buttons


Get the radio buttons using
Expand|Select|Wrap|Line Numbers
  1. document.getElementsByName("isIdba");
  2. // or
  3. document.forms[formName].elements["isIdba"]
then loop over the resulting array.
Reply