F
foreveryouth
Unregistered / Unconfirmed
GUEST, unregistred user!
我把问题简化了一下:
alert(choice.selectedIndex)是0,但是alert(choice.options[0].value)却是空这是
为什么?谢谢各位!!!
function go(){
var choice=document.formshoucang.listshoucang
choice.options[0]=new Option("aa")
choice.options[1]=new Option("bb")
choice.options[0].selected=true
alert(choice.selectedIndex)
alert(choice.options[0].value)
alert(choice.options[choice.selectedIndex].value)
}
<form name="formshoucang">
<p>
<select name="listshoucang" SIZE=20 style="font-family:宋体; width:200;">
</select>
</p>
<p>
<input type="button" name="queding" value="确定" onClick="go()">
<input type="button" name="delete" value="删除" >
</p>
</form>
alert(choice.selectedIndex)是0,但是alert(choice.options[0].value)却是空这是
为什么?谢谢各位!!!
function go(){
var choice=document.formshoucang.listshoucang
choice.options[0]=new Option("aa")
choice.options[1]=new Option("bb")
choice.options[0].selected=true
alert(choice.selectedIndex)
alert(choice.options[0].value)
alert(choice.options[choice.selectedIndex].value)
}
<form name="formshoucang">
<p>
<select name="listshoucang" SIZE=20 style="font-family:宋体; width:200;">
</select>
</p>
<p>
<input type="button" name="queding" value="确定" onClick="go()">
<input type="button" name="delete" value="删除" >
</p>
</form>