Get menu list label

S

Steven

Hi
I'm sure this is a rather basic question but I can't figure it out
I have a menu list as follows

<select name="par" onchange="alert(this.value)">
<option value="1"><"A"</option>
<option value="2"><"B"</option>
<option value="3"><"C"</option>
</select>

When I make a selection I can get the id using this.value, how do I get
the lable ie the A,B orC
 
A

ASM

Steven a écrit :
Hi
I'm sure this is a rather basic question but I can't figure it out
I have a menu list as follows

<select name="par" onchange="alert(this.value)">
<option value="1"><"A"</option>
<option value="2"><"B"</option>

<select name="par" onchange="alert(this.value+'\n'+this.text)">
<option value="1">"A"</option>
<option value="3"><"C"</option>
</select>

When I make a selection I can get the id using this.value, how do I get
the lable ie the A,B orC

document.forms['myForm'].par[document.forms['myForm'].par.selectIndex].text;

brieffly and if in same form

selectedLabel = par.text;
selectedValue = par.value;
 
A

ASM

ASM a écrit :
document.forms['myForm'].par[document.forms['myForm'].par.selectIndex].text;

document.forms['myForm'].par[document.forms['myForm'].par.selectedIndex].text;

..
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top