By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,817 Members | 2,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,817 IT Pros & Developers. It's quick & easy.

forms

P: n/a
I have a form created that lets students pick course from a checkbox
list. But I only want them to be able to select 3 courses max. How
do I write a for loop that will them pick no more than three courses?

Oct 7 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
mr*******@gmail.com wrote:
I have a form created that lets students pick course from a checkbox
list. But I only want them to be able to select 3 courses max. How
do I write a for loop that will them pick no more than three courses?
You don't. You count the checked checkboxes instead when a checkbox was
clicked. Since the corresponding mouse events bubble in all DOMs, you
need only one event listener per event for all checkboxes.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Oct 7 '07 #2

P: n/a
While the city slept, mr*******@gmail.com (mr*******@gmail.com) feverishly
typed...
I have a form created that lets students pick course from a checkbox
list. But I only want them to be able to select 3 courses max. How
do I write a for loop that will them pick no more than three courses?
As mentioned, not a for loop, but you can use the onclick handler to count
the number of selected checkboxes and report an error if more than 3
selected. I've knocked up a quick and dirty example here:
http://www.nigenet.org.uk/stuff/maxselect.php

Hope that helps.

Cheers,
Nige

--
Nigel Moss http://www.nigenet.org.uk
Mail address will bounce. ni***@DOG.nigenet.org.uk | Take the DOG. out!
"Your mother ate my dog!", "Not all of him!"
Oct 8 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.