Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2011
    Posts
    51
    Thanks
    18
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    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

  • Users who have thanked AndrewGSW for this post:

    hunter1611 (12-26-2012)

  • #3
    New Coder
    Join Date
    Jan 2011
    Posts
    51
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Thank you very much!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •