Select控件中如何正确的获取选中的option呢? 对了,页面载入时是空的select,即<select id="lbxAccepter"></select>点击“增加选项”时再加入option的然后再点击增加的option,会出现上述问题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在IE下测试,没有出现lz所说的情况,lz用的是什么浏览器?<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>new page</title><script>function getSelectedOption(obj){ //obj.selectedIndex = obj.selectedIndex; alert(obj.selectedIndex);}function add(){var s=document.getElementById("lbxAccepter");var n=hid.value;hid.value=parseInt(n)+1;var op=new Option(n,n);s.add(op);}</script></head><body><select id="lbxAccepter" onchange=getSelectedOption(this)></select><input type=button onclick=add()><input type=hidden id=hid value=0></body></html> 我知道啦,用了onclick事件,应该用onchange~结贴 帮我看看这段代码,错在哪?谢谢吭,答完给分。。。 关于触发,黑夜即将来到,还是没弄出来 脚本取对象问题,急啊,谢谢大家 页面刷新 层的灵活位置:有实现的可能吗? 客户端插入JS代码为什么没返用????? 问大伙一个很菜的问题,如何获取以名字命名的数组长度啊 不好实现啊!!!! zTree树插件的异步加载刷新节点选中问题。 项目工程文件如何打开? 调用颜色对话框时为什么点击"取消"按钮会是这个效果?? csdn 首页轮换广告
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>new page</title>
<script>
function getSelectedOption(obj){
//obj.selectedIndex = obj.selectedIndex;
alert(obj.selectedIndex);
}
function add(){
var s=document.getElementById("lbxAccepter");
var n=hid.value;
hid.value=parseInt(n)+1;
var op=new Option(n,n);
s.add(op);
}
</script>
</head>
<body>
<select id="lbxAccepter" onchange=getSelectedOption(this)>
</select>
<input type=button onclick=add()>
<input type=hidden id=hid value=0>
</body>
</html>
结贴