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

Thread: Select label

  1. #1
    New to the CF scene
    Join Date
    Oct 2002
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Select label

    Hi,

    I would like to use the label of the selected option in select object?

    If i use "optionName.innerText":
    <select name="optionName" onchange="alert(optionName.innerText)">
    <option value="1" SELECTED>Option 1</option>
    <option value="2">Option 2</option>
    </select>

    The alert returns "Option 1 Option 2".

    But i need only the label of the selected item (ie "Option 1").

    Thank you!

    mares

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    <select name="optionName" onchange="alert(options[selectedIndex].text)">
    <option value="1" SELECTED>Option 1</option>
    <option value="2">Option 2</option>
    </select>

    Not really a 'label', mares....

  • #3
    New to the CF scene
    Join Date
    Oct 2002
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Thank you!


  •  

    Posting Permissions

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