[Javascript] Auto deleselecting a check box

Flavio Gomes flavio at economisa.com.br
Thu Apr 29 14:29:23 CDT 2004


I made a few little changes on the code..

 - set "CHECKED" for default in TYL box
 - added an "if" after the "break" to check TYL box if none was checked
 - changed boxLater to aBoxes[iBox] in "UnCheckCountries()" function


----- Original Message ----- 
From: "Peter Brunone" <peter at brunone.com>
To: <javascript at LaTech.edu>
Sent: Thursday, April 29, 2004 4:18 PM
Subject: Re: [Javascript] Auto deleselecting a check box


> >Likewise, Peter, your solution assumes that the Tell You Later checkbox
> >comes last.  If someone moves it to the top of the list, your code has to
> >be changed.
>
>    It was quick and dirty, to get the job done.  I'm sure we'd get another
question if/when that failed to be sufficient :)
>
> >Also, Peter, your code assumes that the onClick event occurs when a
country
> >box is checked, whereas it will also fire if one is unchecked, so you
> >really need to include the value of the checked property in your logic.
>
>    All that is true, but he didn't ask for code to run through all the
checkboxes and see if any but the "Tell You Later" are checked and if not to
check the TYL box.  Since I'm often guilty of giving *too much* information,
I try to tone it down until someone asks for more.
>
> Cheers,
>
> Peter
>
> Original Message:
> >From: Paul Novitski <paul at novitskisoftware.com>
>
> >Flavio & Peter,
> >
> >I'd quibble with your solution, Flavio, only because you've hard-coded
the
> >number of checkboxes; if (when!) countries are added or removed someone
> >would have to remember to revise the script.
> >
> >Likewise, Peter, your solution assumes that the Tell You Later checkbox
> >comes last.  If someone moves it to the top of the list, your code has to
> >be changed.
> >
> >I'm not saying a script shouldn't be dedicated to a specific html
> >structure!  It's just that I see html content change so much that I try
to
> >save myself a lot of work by making my scripts a bit light on their feet
> >and more forgiving of page format & content changes...
> >
> >Also, Peter, your code assumes that the onClick event occurs when a
country
> >box is checked, whereas it will also fire if one is unchecked, so you
> >really need to include the value of the checked property in your logic.
> >
> >Paul
> >
> >At 11:12 AM 4/29/2004, Flavio Gomes wrote:
> >><script>
> >>function UnCheckTellYouLater(oForm)
> >>{
> >>   countriesbeen = oForm.countriesbeen;
> >>   countriesbeen[3].checked = !(countriesbeen[0].checked ||
> >>countriesbeen[1].checked || countriesbeen[2].checked);
> >>}
> >></script>
> >
> >
> >At 11:14 AM 4/29/2004, Peter Brunone wrote:
> >>Well, you probably don't want to call it in the last checkbox, but
here's
> >>the basic idea:
> >>
> >>function UnCheckTellYouLater() {
> >>     var i = myForm.countriesbeen.length - 1;
> >>     myForm.countriesbeen[i].checked = false;
> >>     }
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.656 / Virus Database: 421 - Release Date: 9/4/2004
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20040429/2402b1b0/attachment.htm>


More information about the Javascript mailing list