This is a discussion on "Deselect select box" within the JavaScript Forum section. This forum, and the thread "Deselect select box are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Deselect select box
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Deselect select box
Hey
I have a select box that allows a maximum of 4 selections before throwing an alert on screen. What the function doesn't do , which I want it to is: When the user ok's the alert, the last selected element stays highlighted. So the user is able to highlight another element, get the message again, but he now has 5 elements highlighted. I want the function to remove the last selected element when they get the alert. Here is the code: function CheckNum()" & _ { var Counter = 0; for (i=0; i<document.myform.theselectbox.length; i++) { if (document.myform.theselectbox[i].selected == true) { counter++; } } if (Counter > 4) { alert(""Limit reached."");" document.myform.theselectbox.value=""""; document.myform.theselectbox.focus; return false; } } I'm sure the answer is staring me in the face, but i'm a touch braindead at the moment and could use a fresh pair of eyes |
|
|
|
|||
|
No matter i've done it.
Can't believe i missed selected=false. doh. |
|
|||
|
Lol and it only took you 9 minutes [:P]
|
|
|||
|
Its the Forumz... they Are so much fun they tend to make us want to ask questions.. but now that you've asked we all know how to do it.. See, how beautiful is that...
|
![]() |
| Tags |
| deselect, select, box |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| chained select box dependable select | thenamenoonehastaken | JavaScript Forum | 0 | Feb 8th, 2008 05:49 |
| Select from many tables! | kool77 | Databases | 2 | May 30th, 2007 20:09 |
| Help Please Select Max Not Working | rosh1e | PHP Forum | 3 | May 13th, 2007 19:11 |
| CSS and select | djme | Web Page Design | 1 | Mar 2nd, 2006 02:05 |
| Select a row and go! Please help? | taymond | JavaScript Forum | 1 | Nov 16th, 2005 15:50 |