Html array field

Results 1 to 2 of 2

Thread: Html array field

  1. #1
    Join Date
    Dec 1969

    Default Html array field

    Hi all,<BR>i have the following,<BR>&#060;input type="checkbox" name="mycbox[]" value="1"&#062;<BR>&#060;input type="checkbox" name="mycbox[]" value="2"&#062;<BR>&#060;input type="checkbox" name="mycbox[]" value="3"&#062;<BR>...<BR>How am i going to write a javascript to check whether the user has checked one of the checkboxes?<BR>I tried document.form.mycbox[i].checked but failed.<BR>Error message: object is null or not defined.<BR>Pls kindly advise.

  2. #2
    Arky Guest

    Default RE: Html array field

    There is no way thats gonna work, at least i never heard of an HTML array. but what you can do is this name the checkboxes sequentially<BR><BR>ckbox1<BR>ckbox2<BR>ckbox3<BR> <BR>then run through the script<BR><BR>var tester = document.all("ckbox"+count).checked<BR><BR>granted this only works in ie so you might want to use the <BR><BR>var whichckbox = "ckbox" + counter;<BR>var TF_is_it_checked = eval("document.Form1."+whichckbox +".checked")<BR><BR>the eval() method actually evaluates everything inthe expression first, its kind of like having 2 equals i would recemmond the this second way.<BR>the counter variable is there because I am assuming you know how to run through a forloop<BR><BR>let me know how it turns out.

Posting Permissions

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