admin管理员组

文章数量:1323330

I have created one dropdown box

<select name="select" id="selectId">
<option id="" value="calendar_Second_Calendar_1285942672.xml">Second Calendar</option>
<option id="" value="calendar_First_Calendar_1285932160.xml">First Calendar</option>
</select>

I can get the selected drop down box value using

document.getElementById("selectId").value

How i can get the name where user is seeing i mean (Second Calendar or First Calendar)

I have created one dropdown box

<select name="select" id="selectId">
<option id="" value="calendar_Second_Calendar_1285942672.xml">Second Calendar</option>
<option id="" value="calendar_First_Calendar_1285932160.xml">First Calendar</option>
</select>

I can get the selected drop down box value using

document.getElementById("selectId").value

How i can get the name where user is seeing i mean (Second Calendar or First Calendar)

Share asked Oct 1, 2010 at 12:37 Shinu ThomasShinu Thomas 5,31612 gold badges62 silver badges88 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 7

Give this a go:

var domNode = document.getElementById("selectId");
var value = domNode.selectedIndex;
var selected_text = domNode.options[value].text;

You can determine the name by a simple if else statements on the given value.

本文标签: phpGetting Selected name of a dropdown using JavascriptStack Overflow