在一个页面中,先执行document.getElementById("thisdiv").innerHTML="<select id='ss'><option value='ff'>aa</option>........</select>";
就是添加了一个SELECT,但是这个SELECT的OPTION很多,有二百个,然后成功看到期望的SELECT出现在页面上。
然后对这个select随便选一个值,执行下面句子
var thisss=document.getElementById(‘ss');
alert("selected index"+ss.selectedIndex);但是很郁闷的是,不管选第几个值,这个alert总是报告"selected index0"。为什么老是0,明明不是0啊,我很崩溃,各位有遇见这种情况吗?可能是哪儿出了问题,请教了!
谢谢。
就是添加了一个SELECT,但是这个SELECT的OPTION很多,有二百个,然后成功看到期望的SELECT出现在页面上。
然后对这个select随便选一个值,执行下面句子
var thisss=document.getElementById(‘ss');
alert("selected index"+ss.selectedIndex);但是很郁闷的是,不管选第几个值,这个alert总是报告"selected index0"。为什么老是0,明明不是0啊,我很崩溃,各位有遇见这种情况吗?可能是哪儿出了问题,请教了!
谢谢。
alert("selected index"+ss.selectedIndex);
应该为alert("selected index"+thisss.selectedIndex);
var thisss=document.getElementById(‘ss');
alert("selected index"+thisss.selectedIndex);
问题还是上面的,仍然等待回答!!!
var str='<select onchange="alert(this.selectedIndex)" size="1" name="D1" id="s1"><option value="a">a</option><option value="b">b</option></select>'
document.body.innerHTML=str;
</script>
document.getElementById("xx").onchange=function(){
alert("selected index"+document.getElementById("xx").selectedIndex);
}
</script>
<select id='mygeness'><option value='3'>3</option><option value='6'>6</option><option value='9'>9</option><option value='12'>12</option><option value='15'>15</option><option value='18'>18</option><option value='21'>21</option><option value='24'>24</option><option value='27'>27</option><option value='30'>30</option><option value='33'>33</option></select><input type='button' onclick='searchpage(1,-1)' value='去到这一页'></button>
是不是你的页面代码头部上加上了w3c之类的html代码,把那些去掉试试