How to count checkboxes checked...
Results 1 to 2 of 2

Thread: How to count checkboxes checked...

  1. #1
    Senior Member
    Join Date
    May 2003
    Posts
    217

    How to count checkboxes checked...

    Hi all, I want to know how to count how many checkboxes checked by user, the result will be processed in submit.asp and then timed with number 2. Lastly, the final result will be displayed to the user. I need the code in JavaScript. Please Help me....



    ---------------------------------------------------------------------------------

    <html>

    <body>
    <form action="submit.asp" name="submit" method="post">
    <p><h3>Stage 1</h3>
    <input type="checkbox" name="cb" value="ON"><br>
    <input type="checkbox" name="cb" value="ON"><br>
    <input type="checkbox" name="cb" value="ON"><br>
    <input type="checkbox" name="cb" value="ON"><br>
    <input type="checkbox" name="cb" value="ON"><br>
    <input type="reset" name="cmdreset" value="Reset">
    <input type="Submit" name="cmdsubmit" value="Submit">
    </P>
    </form>
    </body>

    </html>

    --------------------------------------------------------------------------------

  2. #2
    AO Antique pwaring's Avatar
    Join Date
    Aug 2001
    Posts
    1,409
    Well, you need to first give each checkbox a unique name, then check it's value and see if it is set to 'on' - loop through all the checkboxes on the form and keep a count of the ones that are.
    Paul Waring - Web site design and development.

Posting Permissions

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