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 教师闺蜜祝福语简短