<form name="form1" method="post" action="">
  <input name="a1" type="text" id="a1">
</form>
<table width="100" border="2" cellspacing="0" cellpadding="0">
  <tr>
    <td onClick="form1.a1.value=this.innerText;" style="cursor:hand ">1114</td>
    <td  onClick="form1.a1.value=this.innerText;" style="cursor:hand ">454545</td>
  </tr>
</table>

解决方案 »

  1.   

    <td onClick="this.form1.a1.value==this.innerText;" style="cursor:help ">1114</td>
    这个td元素并不是form容器内的,所以你用this.form.a1是引用不到a1的,既然你已经定义了id,直接引用id名就好了
    <td onClick="document.all.a1.value=this.innerText" style="cursor:pointer">1114</td>
      

  2.   

    我想把表中的所有td都有这个功能,如何一下子写好 ,不用每行都写?我指的是一个table中的所有td.不能影响其他的table.
      

  3.   

    一个表中所有的td都要这样的功能,如何一次性写好,不用每行都去写onclick?
      

  4.   

    把onclick放table里,或者用event对象
      

  5.   

    use js to echo all the td :
    <script>
    for(i=1;i<5;i++){//suppose the table has 5 rows and each row has 10 cells
      document.write("<tr>");
         for(i=1;i<10;i++){
           document.write("<td onclick='..'></td>");
         }
      document.write("</tr>");
    }
    </script>
    or you can use php,asp,jsp to create the html pages