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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2011
    Posts
    182
    Thanks
    139
    Thanked 0 Times in 0 Posts

    Getting the text/label value of a drop down box

    Hello,

    I need your help.

    I am using the code below to attempt to get the text or label value of the drop down box, however, what I am not liking is that it is returning a number of the selected item, as opposed to the text value.

    Code:
    document.getElementById('status').value
    How can I get just the text value of the selected item in question?

    Much thanks and appreciation for all your help.

    Cheers,

    J

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,910
    Thanks
    56
    Thanked 544 Times in 541 Posts
    maybe this:

    Code:
    sel=document.getElementById('status');
    txt=sel.options[sel.selectedIndex].text;
    alert(txt)


  •  

    Posting Permissions

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