469,313 Members | 2,207 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,313 developers. It's quick & easy.

forms

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
2 1366
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
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.

Similar topics

3 posts views Thread by Joshua Russell | last post: by
15 posts views Thread by Joshua Kendall | last post: by
3 posts views Thread by Lloyd Sheen | last post: by
3 posts views Thread by Geraldine Hobley | last post: by
21 posts views Thread by Dan Tallent | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.