Results 1 to 4 of 4

Thread: Looping thru dynamically built checkboxes each with same name

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Posts
    94

    Question Looping thru dynamically built checkboxes each with same name

    Hi,

    I have a dynamically built webpage (thru ASP) which creates an indefinite number of checkboxes, each with the same name. I have a javascript function being called from the button onClick event in the form. The function is supposed to loop thru each checkbox and return false if none of them are checked. How can this be done? Do I need to use some kind of index to reference each one separately?

    Thanks in advance,
    Mark.

  2. #2
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769
    Code:
    var i = 0;
    var blnChecked = false;
    
    for (i = 0; i < frm.chk.length; i++) {
    	if (frm.chk[i].checked) blnChecked = true;
    }
    
    return blnChecked

  3. #3
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    just a point to bear in mind if the ASP creates only one checkbox
    then it won't be an array

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Posts
    94

    Talking Thanks!

    Thanks guys! That's cool!

Posting Permissions

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



Click Here to Expand Forum to Full Width