Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-26-2012, 07:48 PM   PM User | #1
hunter1611
New Coder

 
Join Date: Jan 2011
Posts: 30
Thanks: 11
Thanked 0 Times in 0 Posts
hunter1611 is an unknown quantity at this point
Dynamically deselecting HTML select menu items

On a page with an HTML form, I have two different select menus. When an item is select, my Javascript functions dynamically load data into the form, based on which item was selected. I've run into a bug when there is one item selected in one menu, and an item selected in the other. Is there a way to unselect all menu items in one of the select menus using Javascript?

The idea I had is that when one menu item is selected, my Javascript code will load data into the form AND deselect any active menu items from the other select menu in order to prevent the bug that arises. Is this possible?

(For the record, I'm not much a Javascript programmer....I just fumble my ways through functions as I need them).

Thank you!

Last edited by hunter1611; 12-26-2012 at 08:21 PM..
hunter1611 is offline   Reply With Quote
Old 12-26-2012, 08:09 PM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
To de-select all items from a select:

Code:
document.getElementById('selectid').selectedIndex=-1;
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Users who have thanked AndrewGSW for this post:
hunter1611 (12-26-2012)
Old 12-26-2012, 08:19 PM   PM User | #3
hunter1611
New Coder

 
Join Date: Jan 2011
Posts: 30
Thanks: 11
Thanked 0 Times in 0 Posts
hunter1611 is an unknown quantity at this point
Thank you very much!
hunter1611 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 04:30 AM.


Advertisement
Log in to turn off these ads.