Deselect select box

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.



 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Closed Thread
 
LinkBack Thread Tools
  #1  
Old Feb 6th, 2004, 12:50
Junior Member
Join Date: Aug 2003
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!

  #2  
Old Feb 6th, 2004, 12:59
Junior Member
Join Date: Aug 2003
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
No matter i've done it.

Can't believe i missed selected=false.

doh.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #3  
Old Feb 6th, 2004, 13:17
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
Lol and it only took you 9 minutes [:P]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #4  
Old Feb 6th, 2004, 13:41
Highly Reputable Member
Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
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...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Tags
deselect, select, box

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 22:00.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42