你確定你有定義form1?
你確定你有定義txtname?
你確定txtname包含在form1之內?

解决方案 »

  1.   

    <form name="form1">
    <input type="text" name="txtname" value="value">
    </form>
    <input type="button" onclick="form1.txtname.value">
    <input type="button" onclick="document.all.txtname.value">
    <input type="button" onclick="document.forms[0].txtname.value">
      

  2.   

    onclick="form1.txtname.value"
    这是个什么东西?
    应该是onclick=submit吧。
      

  3.   

    "document.forms[0].txtname.value" 并不是一个语句,它不完整,所以会出错,<input type="button" onclick="document.forms[0].txtname.value">————这句单击以后想完成什么功能呢?
      

  4.   

    <form name="form1">
    <input type="text" name="txtname" value="value">
    </form>
    <input type="button" onclick="alert(form1.txtname.value)">
    <input type="button" onclick="alert(document.all.txtname.value)">
    <input type="button" onclick="alert(document.forms[0].txtname.value)">