最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Getting Selected name of a dropdown using Javascript - Stack Overflow

programmeradmin1浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论