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 生日广州男生祝福语简短