select下拉列表的onChange事件javascript

/ / 2023-05-12   阅读:2558
select下拉列表的onChange事件...

select onChange事件,实现效果为,选择下拉框中的一个把他显示出来.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>select onChange事件</title>
</head>
<body>
            <select id="EffectiveDateSel" onChange="DispayPrice();">
 
                <option>切换 <b class="caret"></b></option>
                <option value="121.473701,31.230416,200000">上海市</option>
                <option value="116.407526,39.90403,100000">北京市</option>
                <option value="103.826308,36.059421,620100000000">兰州市</option>
                <option value="113.264434,23.129162,510000">广州市</option>
 
            </select>
<span id="cityse"></span>
 
<script>
function DispayPrice()
    {
        var nSel = document.getElementById("EffectiveDateSel");
        var index = nSel.selectedIndex; // 选中索引
        var text = nSel.options[index].text; // 选中文本
        var value= nSel.options[index].value; // 选中值
        document.getElementById("cityse").innerHTML=text+"----"+value;
 
    }
</script>
</body>
</html>


我要评论

昵称:
验证码:

最新评论

共0条 共0页 10条/页 首页 上一页 下一页 尾页
意见反馈