How to get a selected value from <Select> using DOM

R

Raghuram Banda

Hi All,

Can any one help me, how to get the selected value from <Select> tag
using DOM
I tried with
document.getElementById("selectTagId").getAttribute("value") it's
working fine with IE but not with NN I have checked it on NN 7.1

Thanks in advance
 
L

Lasse Reichstein Nielsen

Raghuram Banda said:
Can any one help me, how to get the selected value from <Select> tag
using DOM
I tried with
document.getElementById("selectTagId").getAttribute("value") it's
working fine with IE but not with NN I have checked it on NN 7.1

document.getElementById("selectTagId").value
works in modern browsers. For Nestscape 4 and other old browsers,
you must get the value from the selected option (works in newer
browsers too):

var sel = document.getElementById("selectTagId");
sel.options[sel.selectedIndex].value;

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top