javascript获取select值的方法分析
本文实例讲述了javascript获取select值的方法。分享给大家供大家参考。具体分析如下:
1.获取显示的汉字
document.getElementById("bigclass").options[window.document.getElementById("bigclass").selectedIndex].text
2.获取数据库中的id
window.document.getElementById("bigclass").value
3.获取select组分配的索引id
window.document.getElementById("bigclass").selectedIndex
例子:
<selectname="bigclass"id="bigclass"onChange="javascript:updatePage2();"> <optionvalue=""selected="selected">ajax实验</option> <optionvalue="4">我适宜市哈</option> </select>
使用:
document.getElementById("bigclass").options[window.document.getElementById("bigclass").selectedIndex].text
结果是:我适宜市哈
使用:
window.document.getElementById("bigclass").value
结果是:4
使用:
window.document.getElementById("bigclass").selectedIndex
结果是:1
希望本文所述对大家的javascript程序设计有所帮助。
热门推荐
10 读书祝福语女生短句简短
11 感谢同事新婚祝福语简短
12 感谢教官文案祝福语简短
13 员工聚会蛋糕祝福语简短
14 元宵发客户祝福语简短
15 给团队信心祝福语简短
16 医美的祝福语大全简短
17 异国姻缘的祝福语简短
18 兄妹拍照祝福语简短的话