selected text for <option> tag

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sreemathy2000
    New Member
    • Oct 2007
    • 40

    selected text for <option> tag

    I have the below code in the form for the select dropdown in my web page.

    how can i get the selected text from javascript.

    i was able to get the value, but text shows as undefined.

    Code:
    <SELECT name="queue" id="queue"><OPTION selected value="0">Select reason</OPTION><option value="Residential Tier 1 Chat" text="Account Information">Account Information</option><option value="NEW Residential Tier 1 Chat" text="Billing Inquiry">Billing Inquiry</option><option value="Residential Tier 2 Chat" text="Browsing/Connectivity Issues">Browsing/Connectivity Issues</option><option value="Residential Tier 2 Chat" text="Email Issues">Email Issues</option><option value="NEW Residential Tier 4 Chat" text="Other">Other</option><option value="NEW Residential Tier 6 Chat" text="Product Questions">Product Questions</option><option value="NEW Residential Tier 3 Chat" text="Sales">Sales</option></SELECT>
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    Hope this will help you.

    [HTML] var sel=document.ge tElementById('q ueue').selected Index;
    alert(document. getElementById( 'queue').option s[sel].text);[/HTML]


    Regards
    Ramanan Kalirajan

    Comment

    • sreemathy2000
      New Member
      • Oct 2007
      • 40

      #3
      yep. thanks. it worked

      Comment

      • RamananKalirajan
        Contributor
        • Mar 2008
        • 608

        #4
        No Probs, keep moving forward

        Regards
        Ramanan Kalirajan

        Comment

        Working...