如何获取select下拉框的值:
1.下拉框的option没有value属性时
复制代码 代码如下:
<select id="param1">
<option>学号</option>
<option>姓名</option>
<option>年龄</option>
</seclect>
<script>
window.onload = funciton(){
var param = document.getElementById("param1");
param.onchange = getParam(){
var text = param.value;
}
}
</script>
2.下拉框的option有value属性时
复制代码 代码如下:
<select id="param1">
<option>学号</option>
<option>姓名</option>
<option>年龄</option>
</seclect>
<script>
window.onload = funciton(){
var param = document.getElementById("param1");
param.onchange = getParam(){
var selectIndex = param.selectIndex; //获得被选项的引索号
var text = param.options[selectIndex].text;
</script>
1.下拉框的option没有value属性时
复制代码 代码如下:
<select id="param1">
<option>学号</option>
<option>姓名</option>
<option>年龄</option>
</seclect>
<script>
window.onload = funciton(){
var param = document.getElementById("param1");
param.onchange = getParam(){
var text = param.value;
}
}
</script>
2.下拉框的option有value属性时
复制代码 代码如下:
<select id="param1">
<option>学号</option>
<option>姓名</option>
<option>年龄</option>
</seclect>
<script>
window.onload = funciton(){
var param = document.getElementById("param1");
param.onchange = getParam(){
var selectIndex = param.selectIndex; //获得被选项的引索号
var text = param.options[selectIndex].text;
</script>
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“如何获取select下拉框的值(option没有及有value属性)”评论...