PDA

Click to See Complete Forum and Search --> : RADIO buttons undefined


richeyb
Aug 2nd, 2001, 05:23 AM
i have the scenario

<form name="monkey">

<input type="radio" name="number" value="1">1<br>
<input type="radio" name="number" value="2">2<br>

</form>

and the jscript:

function whatever()
{
var a = monkey.number.value;
alert(a);
}

and the alert says undefined.

does anyone know why?

Richard

brock landers
Aug 2nd, 2001, 09:26 AM
Yep

You have two tags called Monkey - in order to reference one of the items you must virst loop through the collection of all tags called Monkey - this is how I do it:-

var collection = document.all["Monkey"];

for (var i=0;i<collection.length;i++)
alert(collection[i].value);