By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,360 Members | 1,405 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,360 IT Pros & Developers. It's quick & easy.

selected text for <option> tag

P: 40
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.

Expand|Select|Wrap|Line Numbers
  1. <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>
Nov 5 '08 #1
Share this Question
Share on Google+
3 Replies


RamananKalirajan
100+
P: 607
Hope this will help you.

[HTML] var sel=document.getElementById('queue').selectedIndex ;
alert(document.getElementById('queue').options[sel].text);[/HTML]


Regards
Ramanan Kalirajan
Nov 5 '08 #2

P: 40
yep. thanks. it worked
Nov 5 '08 #3

RamananKalirajan
100+
P: 607
No Probs, keep moving forward

Regards
Ramanan Kalirajan
Nov 5 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.