[thelist] Javascript Help: Forms

Tom Dell'Aringa pixelmech at yahoo.com
Wed Jul 3 19:05:01 CDT 2002


Well, it seems to me undefined so you have no valid reference to the
object (thus the error). It doesn't know what to check to see if its
false. your onClick fires off N() and then looks for the value of i,
nada.

Not sure what you want to do with this, but I'm sure others would
point out that the functionality of a radio group is that one is
always selected by default, so you are kind of busting that - but you
may be doing it for a good reason...may be...
--- Timothy Martens <timfm at hawaii.rr.com> wrote:
> 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 !


=====
var me = tom.pixelmech.webDeveloper();
http://www.pixelmech.com/

__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com



More information about the thelist mailing list