我想给下面这段显示赋值<input type="text" name="mobile_0" id="mobile_0" size="6">于是采用的是:
document.forms[7].elements["mobile_0"].value = 1;但是javascript 是在page load好之后执行的,于是就什么都没显示了。请问高手怎么办啊?

解决方案 »

  1.   

    document.forms[7]["mobile_0"].value = 1;
      

  2.   

    html 文件确实没问题,我的xsl和xml转换生成的html文件,所以有问题了。document.forms[7]["mobile_0"].value = 1;这句和document.forms[7].elements["mobile_0"].value = 1;是一回事的。
      

  3.   

    为什么不用document.getElementById('mobile_0').value = 1 呢?
      

  4.   

    我的xsl和xml转换生成的html文件, 所以document.getElementById('mobile_0').value = 1找不着对象。
      

  5.   

    我看你问题的时候,理解的是
    有一个表单,里面有这么一个字段
    <input type="text" name="mobile_0" id="mobile_0" size="6">但我为什么用
    document.forms[7].elements["mobile_0"].value = 1;无法赋值,请问为什么
      

  6.   

    你用document.forms[7][第几个元素].value看看
      

  7.   

    或者这样写
      document.forms[7][第几个元素]("mobile_0").value
      

  8.   

    document.forms[0].elements["mobile_0"].value
    第一个表单下有一个elements["mobile_0"]元素:<input type="Text" name="mobile_0" id="mobile_0"/>
     我用你的那个方法document.forms[0].elements["mobile_0"].value
    去给textbox赋值,错误提示不支持此方法
      

  9.   

    window.onload=function
    {
    document.forms[7].elements["mobile_0"].value = 1;
    }
      

  10.   

    用下面的代码试试看document.forms[7].childNode("mobile_0").value
      

  11.   

    上面少加了s
    用下面的代码试试看document.forms[7].childNodes("mobile_0").value