用javascript完全可以实现,不复杂

解决方案 »

  1.   


    以下代码已经经过我测试通过:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>文本复制</title>
    </head><body>
    <form name="form1" method="post" action="">
      <table width="75%" border="1">
        <tr>
          <td>文本框1</td>
          <td><input name="id1" type="text" id="id1" onkeyup="javascript:document.form1.id2.value=document.form1.id1.value;"></td>
        </tr>
        <tr>
          <td>文本框2</td>
          <td><input name="id2" type="text" id="id2"></td>
        </tr>
      </table>
    </form>
    </body>
    </html>测试的时候用了onkeydown,onkeypress等都不行。
    onkeyup=""就可以了。
      

  2.   

    wellsoon(wellsoon)的这种方法可行,但是有一个缺点,就是当我按住一个键不动时,文本框id1改变,但文本框id2不变。
    你还可以这样写:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>文本复制</title>
    </head><body>
    <form name="form1" method="post" action="">
      <table width="75%" border="1">
        <tr>
          <td>文本框1</td>
          <td><input name="id1" type="text" id="id1" onpropertychange="javascript:document.form1.id2.value=document.form1.id1.value;">
          </td>
        </tr>
        <tr>
          <td>文本框2</td>
          <td><input name="id2" type="text" id="id2"></td>
        </tr>
      </table>
    </form>
    </body>
    </html>
    这样即使你按主某一个键不动,当id1文本框改变的时候,id2文本框同时改变,并且中间的延迟很小。