Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: How to grab radio button values


Message #1 by anne.do@c... on Thu, 27 Feb 2003 20:54:43
YEah, that's how I think it should work, too, just like everybody else in
the world, but in fact you have to say:

if (document.UpdateForm.Answer[1].checked) //second button is checked {
	return false;
}

-----Original Message-----
From: anne.do@c... [mailto:anne.do@c...]
Sent: Thursday, February 27, 2003 8:55 PM
To: javascript
Subject: [javascript] How to grab radio button values


I have two radio buttons with the same name:

<form name="UpdateForm">
<input type="radio" value="1" name="Answer" checked>Yes
<input type="radio" value="0" name="Answer">No
</form>

In my javascript I want grab the value of the radio button but the code
below doesn't work?  How can I ask JS if the value is equal to 0 or 1?


function Check_Form( )
{
if ((document.UpdateForm.Answer.value=="0") //this doesn't grab the value
         return false;
}



  Return to Index