首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

改正下小弟我的异常代码 ,多谢

2012-03-28 
改正下我的错误代码 ,谢谢oView.innerTextdocument.all( oSelect1 ).options[selectedIndex].value其

改正下我的错误代码 ,谢谢
oView.innerText=document.all( "oSelect1 ").options[selectedIndex].value;
其中oView是个DIV  
  oSelect1是个下拉框
      提示错误   没有selectedIndex的定义
   




[解决办法]
oView.innerText=document.all.oSelect1.options[selectedIndex].value;
[解决办法]
下拉框的value就是其选中的option的value...
[解决办法]
oView.innerText=document.all.oSelect1.options[selectedIndex].value;
selectedIndex为数值就012345……
[解决办法]
实在要写的话

oView.innerText=document.all.oSelect1.options[document.all.oSelect1.selectedIndex].value;
[解决办法]
<body>
<form>
<select id= "oSelect1 " onchange= "document.all.oView.value=this.options[this.selectedIndex].value ">
<option value= "1 "> 1 </option>
<option value= "2 "> 2 </option>
</select>
<input type= "text " id= "oView " value= " ">
</form>

热点排行