Javascript error

Results 1 to 2 of 2

Thread: Javascript error

  1. #1
    Join Date
    Dec 1969

    Default Javascript error

    I am generating checkboxes dynamically with same name but with different values, basing on a number of records a recordset displays.<BR>I need to have a button to select all checkboxes.<BR>The code is shown below for the button.<BR><BR>&#060;input type="button" name="SelectAll" value="Select All on this page" onclick="Javascript: for(i=0;i&#060;&#060;%=Request.Cookies("StateGroup ")("TotalRefs")%&#062;;i++){window.document.frmSta te.chkRef[i].checked = true;}"&#062;<BR><BR>This works fine if I have more than 1 record. If 1 record is displayed, it is giving Javascript error. Why is the JS failing if the value of Request.Cookies("StateGroup")("TotalRefs") = 1 ??<BR><BR>Thanks in advance for your help.

  2. #2
    Join Date
    Dec 1969

    Default Because then there is no array

    When you only have *one* form field of a given name--no matter *what* it&#039;s type--then no array is created in the DOM.<BR><BR>Sneaky trick: Have a hidden form field with the same name, just to ensure you get an array.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts