SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    How could I count how many checkboxes are checked? There are around 100 checkboxes and I don't want the user to check more than 10.
    Thanks,

  2. #2
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Hartmann,

    Try something like this:

    Code:
    <script>
    var number=0;
    function checkit(){
    number=0;
    for(j=0;j<document.forms[0].elements.length;j++){
    if(document.forms[0].elements[j].type=="checkbox" && document.forms[0].elements[j].checked==true){
    number++;
    }}
    if(number>10){
    alert('You\'ve checked more than 10 checkboxes.  Only check ten');
    }}
    </script>
    Hope that helps,
    aDog

  3. #3
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did this help you?

  4. #4
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Worked like a charm! Many thanks!!

  5. #5
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great, just remember to add to my karma

    aDog

  6. #6
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    I gave you some the day you replied...


Bookmarks

Posting Permissions

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