赋什么值?输入框的内容?  document.getElementById("a").value = ***;

解决方案 »

  1.   

    document.getElementById("xxx").value;
    或document.forms[0].xxx.value;
      

  2.   

    document.getElementById("a").value =="";
      

  3.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    <script language="javascript">
    document.getElementById("textfield").value="ssss";</script>
    </head><body>
    <form name="form1" method="post" action="">
      <input type="text" name="textfield">
    </form>
    </body>
    </html>
    提示:document.getelementbyid 为空或不是对象
      

  4.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title></head><body>
    <form name="form1" method="post" action="">
    <input type="text" name="textfield">
    <script language="javascript">
    document.getElementById("textfield").value="ssss";</script>
    </form>
    </body>
    </html>
    再前面html还没生成,当然找不到,或写在onload函数里面
      

  5.   

    <input type="text" name="textfield" id="textfield"> //加个id
      

  6.   

    <input type="text" name="textfield">document.getElementById是取id所以id不能为空;;
      

  7.   

    解决.谢谢 mingxuan3000(铭轩)to  s_liangchao1s(求学) getElementById可以取到 name="?" 不一定要id 
    如下<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    <script language="javascript">
    function inita()
    {
    document.getElementById("a").value="ssss";
    }
    </script>
    </head><body onLoad="inita()">
    <form name="form1" method="post" action="">
      <input type="text" id="a" >
      
    </form>
    </body>
    </html>
    或<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title></head><body >
    <form name="form1" method="post" action="">
      <input type="text" id="a" >
      <script language="javascript">
    document.getElementById("a").value="ssss";
    </script>
    </form>
    </body>
    </html>
    谢谢大家的关注
      

  8.   

    document.getElementById是取id所以id不能为空;;