日期:2014-05-18  浏览次数:20611 次

急~~~~~~~~~~~~~~~~~~~里面的代码为何取不到值?怎么改呢?
<SCRIPT   language=JavaScript>
function   setStyle()   {
var   theValue   =   w.value;
      //alert(theValue);
      //if   (theValue!= " ")   {
      //t_find.getFind(theValue);
      //}   else   {
      //alert(t_find.msgList[99]);
      //}
}
</SCRIPT>

<FORM   action= " "   method=post   name=myform>
<input   name= "w "   type= "text "   id= "w ">
<input   type= "button "   name= "Submit "   onclick=setStyle()   value= "查询 ">
</FORM>

点击后显示“   w   未定义”


------解决方案--------------------
function setStyle() {
var theValue = this.myform.w.value;
alert(theValue);
}
------解决方案--------------------
w前加一个form名就好了
------解决方案--------------------
var theValue = document.all.w.value; 这也是可以的
------解决方案--------------------
var theValue = document.forms[0].w.value;