Re: Javascript question with checkboxes

by Romek aka webadmin <www(at)>

 Date:  Mon, 23 Oct 2000 16:02:05 +0000
 To:  Rajnish Bhaskar <r.bhaskar(at)>
 Cc:  hwg-languages(at)
 In-Reply-To:  ac
  todo: View Thread, Original
At 10:38 23-10-00 +0100, you wrote:
>function clearBoxes(start, end) {
>for (var i=start; i<=end; i++) {
>      return document.QuestionnaireOne[i].checked= false;
>   } // end loop
>} // end method clearBoxes()

  I tried to use:
     document.QuestionnaireOne[""+i].checked= false;
  by writing ""+i  I force to use name of the element
  that should work in IE but does not work in Opera 3.6x.

  I tried several varation of the function and the 
  only one that works consistently is the one below.

  function clearBoxes(start,end) {
    for (var i=start; i<=end; i++) {
  //    document.QuestionnaireOne[i].checked= false;
    } // end loop
  } // end clearBoxes()

 Mind however that you have to count elements in the form
 (first one has number zero)
 So when you call rewritten function you have to use
 different start and end numbers:

  < b>6.  Have you ever used a personal computer?</b>
  < br>
  < INPUT TYPE="RADIO" NAME="req_6" VALUE="Yes">Yes
  < br>
  < INPUT TYPE="RADIO" NAME="req_6" VALUE="No" onClick="clearBoxes(20, 26);">

>And in the No radio button I set the onClick="clearBoxes(7, 13) 
>where 7 and 13 are the start and end values of the checkboxes 
>associated with this question.
>However, this doesn't work.  It doesn't give me an error, 
>it's just that nothing happens.  Can someone help?
>If this is unclear, you can find the page in question at: 
>Thanks very much in advance,
>Rajnish Bhaskar
>IT Education Unit, University of Glasgow

Romek Zylla
~~~~~~~~~~~  after all the work done by Micro$oft (R)  ~~~~~~~~~~
        Personal Computer Science is an experimental one (C)

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA