[Javascript] Re: turning on checkboxes

Jeff Walters jeff at cybermill.com
Mon Aug 13 15:42:40 CDT 2001


> I'm having trouble getting your solution working. It says
> document.memberForm.element is null or not an object. After printing
> alert 1, it fails before alert 2. Any suggestions on how I might test
> for nulls?
> 
> function selectAll(){
> for ( var i =0; i < document.memberForm.length; i++){
> alert("alert 1");
> if ( document.memberForm.element[i] != null){
> alert("alert 2");
> if ( document.memberForm.element[i].type
> == "checkbox"){
> alert("alert 3");
> document.memberForm.element
> [i].checked = TRUE;
> }
> }
> }
> }
Every where you have:
element[i]
Change to:
elements[i]

I would also make this change as well. Not sure how important case is for
Boolean declarations, but everything I've seen had 'true' and 'false' in
lowercase.
document.memberForm.elements[i].checked = true;

Hope this is helpful,
Jeff




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jeff Walters   (314) 962-4024

Cybermill Communications
8616 Joseph Ave
St. Louis, MO 63144
Jeff at cybermill.com
http://www.cybermill.com/




More information about the Javascript mailing list