如何在javascript中获取下拉列表selecteditem [英] how to get the dropdown selecteditem in javascript

查看:105
本文介绍了如何在javascript中获取下拉列表selecteditem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的页面上有一个下拉列表,我想使用其标记名"select"在javascipt中获得列表.现在我的问题是如何在javascript中获取下拉列表选择的项目.

在此先感谢
Seshu

Hi All,

I have a drop down lists in my page i would like get the list in javascipt by using its tagname ''select''. Now my question is how to get the dropdown list selected item in javascript.

Thanks in Advance
Seshu

推荐答案

类似的东西:

something like this:

function GetSelectedValue(selectItem)
{
    var index = document.getElementById(selectItem).selectedIndex;

    alert("value =" + document.getElementById(selectItem).value);
    alert("text =" + document.getElementById(selectItem).options[index].text);
}


这篇关于如何在javascript中获取下拉列表selecteditem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆