Booooze
12-26-2003, 06:47 PM
hi,
i have some radio buttons and i want to decide which one is been clicked,ez right? yeah ( i dounf code for it), but now i have an error. it used to work, but all of a sudden it doesnt. and i cant remember what i did. i think it seems to keep counting for radio buttons and doesnt stop, which is why it would be "object expected". im going insane so this is what i have to ask of you. find my error. lol, please and thank you!
this is bits and peices
<CODE>
function valbutton() {
// place any other field validations that you require here
// validate myradiobuttons
myOption = -1;
for (i = 0 ; i < document.myform.myradiobutton.length; i ++)
{
if (document.myform.myradiobutton[i].checked == true)
{
myOption = i;
}
}
if (myOption == -1) {
alert("You must select an answer");
return false;
}
alert("You selected button number " + myOption
+ " which has a value of "
+ document.myform.myradiobutton[myOption].value);
</CODE>
<CODE>
<form name="myform">
<input type="radio" value="1st value" name="myradiobutton" >1.)<br />
<input type="radio" value="2nd value" name="myradiobutton" >2.)<br />
<input type="radio" value="3rd value" name="myradiobutton" >3.)<br />
<input type="radio" value="4th value" name="myradiobutton" >4.)<br />
<br />
<input type="button" name="submitit" onClick="valbutton()" value="Next" />
<input type="reset" name="reset" value="Clear" />
</CODE>
Thanks!
i have some radio buttons and i want to decide which one is been clicked,ez right? yeah ( i dounf code for it), but now i have an error. it used to work, but all of a sudden it doesnt. and i cant remember what i did. i think it seems to keep counting for radio buttons and doesnt stop, which is why it would be "object expected". im going insane so this is what i have to ask of you. find my error. lol, please and thank you!
this is bits and peices
<CODE>
function valbutton() {
// place any other field validations that you require here
// validate myradiobuttons
myOption = -1;
for (i = 0 ; i < document.myform.myradiobutton.length; i ++)
{
if (document.myform.myradiobutton[i].checked == true)
{
myOption = i;
}
}
if (myOption == -1) {
alert("You must select an answer");
return false;
}
alert("You selected button number " + myOption
+ " which has a value of "
+ document.myform.myradiobutton[myOption].value);
</CODE>
<CODE>
<form name="myform">
<input type="radio" value="1st value" name="myradiobutton" >1.)<br />
<input type="radio" value="2nd value" name="myradiobutton" >2.)<br />
<input type="radio" value="3rd value" name="myradiobutton" >3.)<br />
<input type="radio" value="4th value" name="myradiobutton" >4.)<br />
<br />
<input type="button" name="submitit" onClick="valbutton()" value="Next" />
<input type="reset" name="reset" value="Clear" />
</CODE>
Thanks!