- Create Account

CheckTree and Limiting # of Selections

Forums > "Miscellaneous" Scripts > CheckTree and Limiting # of Selections
Author
Message

1) mike Group: Guests
IP: 66.207.--.--
Hi,
is there any way for us to limit the # of checkboxes a user can select in a given subcategory? If not what would be a good place to start. I want to limit the # of selections on each click, comparing the # of boxes checked in that sub-cat with another variable and throwing up an alert if they have reached a limit.

thanks in advance,
mike

2) Angus Turnbull Group: Moderators
Posts: 4042 Joined: 7 Dec 2003 Location: New Zealand IP: 203.173.--.--
Whoo, I haven't edited this script in quite a while :). I'd check in the click handler, count the sibling elements of the clicked one, and if there's too many cancel the click event. That's a fair amount of programming though, not a one-line addition.

- Angus.

3) mike Group: Guests
IP: 66.207.--.--
thanks for the info.
thats what i was planning on doing. I figure just right at the top of the click event i would first determine if they are checking or unchecking. if checking count siblings in the sub-section, if count of siblings > max checked then break otherwise allow the click and increment counter.

i  noticed you do have a count function in there that (when enabled) does a count of the # of boxes checked, i may see if i can hook into that and just enforce a max count check before it updates the status.

thanks,
mcm

Post a Reply:

You are not logged in, and will be posting anonymously as a guest. If you want to post using an account, please login at the top of this page.