[thelist] Javascript Help: Forms
Amazon Paulo
Amazon.Paulo at Amazoniacelular.com.br
Thu Jul 4 09:36:01 CDT 2002
Hi Timothy,
I guess the line that's wrong should be like this:
if (document.choice.r[i].checked == false) {...}
If you use "=" instead of "==", you're not comparing the values, but
assigning them.
/Paulo Guedes
-----Original Message-----
From: Timothy Martens [mailto:timfm at hawaii.rr.com]
Sent: Wednesday, July 03, 2002 9:00 PM
To: thelist at lists.evolt.org
Subject: [thelist] Javascript Help: Forms
Hi -- another strange request. I have a form with four radio buttons.
The initial state of the radios is that NONE of them are "checked." I
want the function to make "checked = true" the first radio (r[0]) and
"return" when the user clicks anywhere in the document body and none are
checked. Subsequently (when a radio is checked) clicks will cycle
through the radio sequence -- this part works fine. It's just the
initial non-checked which is messing me :\ mahalo!
function N() {
//NEXT LINE IS WHAT'S ERRORING
if (document.choice.r[i].checked = false)
{document.choice.r[0].checked = true; return;}
//The rest works
var rad = document.choice.r;
for(var i=0; i < rad.length; i++) {
if(rad[i].checked) {
var nextRad = (i+1 >= rad.length) ? 0 : i+1;
rad[nextRad].checked = true;
checkedbutton = nextRad;
//locked = 0;
return;
}
}
}
document.onclick = N;
<form name="choice">
<input type="radio" name="r" value="bg" />bg
<input type="radio" name="r" value="txt" />txt
<input type="radio" name="r" value="lnk" />lnk
<input type="radio" name="r" value="blk" />blk
</form>
t.
::::::::::::::::::::::::
<!--timothy martens
timfm at hawaii.rr.com-->
--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !
More information about the thelist
mailing list