Forum Moderators: mack

Message Too Old, No Replies

CheckBox

Limit the amount of checks

         

Shuvi

8:11 pm on Aug 4, 2004 (gmt 0)

10+ Year Member



How do I limit the amount of checkbox a user can check? I want to display an alert if they check more than 6 boxes.

Please help!
Shuvi

coopster

8:28 pm on Aug 4, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You will probably have to use javascript to loop through the element's checked attribute. However, I would still use a server-side edit to make sure.

Shuvi

9:02 pm on Aug 4, 2004 (gmt 0)

10+ Year Member



Do you have an example I can look at?

lorax

2:03 am on Aug 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I don't think you'll need to do a loop but rather you could use a Javascript onClick event to both increment a counter and then check it against a preset limit.

You'll also need to know if the checkbox has been unchecked. You can do that by counting the number of times a particular box is clicked on. Assuming the default is unchecked then the odd number clicks will equal checked and the evens unchecked. Code example? Not unless someone takes the time to write it and my Javascript skills were never very good.

Shuvi

12:44 pm on Aug 5, 2004 (gmt 0)

10+ Year Member



Thank you!