SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist mrwooster's Avatar
    Join Date
    Jan 2006
    Posts
    518
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting selected option in dropdown box in IE

    I am trying to get the value of the selected option in a dropdown box... in firefox this code works:

    Code:
    selected = document.getElementById(id).value;
    But it doesn't work in Internet Explorer... how do I do it in IE?

    Thanks

  2. #2
    SitePoint Evangelist
    Join Date
    Apr 2008
    Location
    Dublin, Ireland
    Posts
    461
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This should work in both:-

    Code:
    var select = document.getElementById(id);
    var selected = select.options[select.selectedIndex].value;

  3. #3
    SitePoint Evangelist mrwooster's Avatar
    Join Date
    Jan 2006
    Posts
    518
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks... works a treat


Bookmarks

Posting Permissions

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