Click to See Complete Forum and Search --> : JScript - Radio Buttons


Superfly1611
01-13-2004, 10:41 AM
Hi - been a while since i asked for help.....
I have an Radio Button HTML Control with 10 options...
<input type="radio" id="A5" name="A5" value="1" onclick="Q5();" />1
<input type="radio" id="A5" name="A5" value="2" onclick="Q5();" />2
<input type="radio" id="A5" name="A5" value="3" onclick="Q5();" />3
<input type="radio" id="A5" name="A5" value="4" onclick="Q5();" />4
<input type="radio" id="A5" name="A5" value="5" onclick="Q5();" />5
<input type="radio" id="A5" name="A5" value="6" onclick="Q5();" />6
<input type="radio" id="A5" name="A5" value="7" onclick="Q5();" />7
<input type="radio" id="A5" name="A5" value="8" onclick="Q5();" />8
<input type="radio" id="A5" name="A5" value="9" onclick="Q5();" />9
<input type="radio" id="A5" name="A5" value="10" onclick="Q5();" />10

I then have a javascript that is supposed to determine which option is selected...
function Q5()
{
var i
for(i=0;i<=9;i++)
{
if(document.form.A5(i).checked=true)
{
alert(i);
}
}
}

instead of determining which one is selected it actually selects the option(i) so by the time the for loop gets to i=9 it has selected the 9th option and then alert("9"); to tell me so.
I don't get it
I don't tell it to select a different option
What am i doing wrong?:confused:

Pittimann
01-13-2004, 10:44 AM
Hi!

if(document.form.A5[i].checked==true)

Cheers - Pit

Superfly1611
01-13-2004, 04:01 PM
LOL - sorry
No sleep plus work makes Superfly a very dumb creature indeed