onclick="show(t1)">-->onclick="show(this)">
document.all.t2.value=document.all.t2.value+document.all.a.value
-->
document.all.t2.value=document.all.t2.value+a.t1.value

解决方案 »

  1.   

    <script language=javascript>
    function show(a){
    a.t2.value=a.t2.value+a.t1.value}
    </script>
    <form name="form1" method="post" action="">
    t1:<input type="text" name="t1">
    t2:<input type="text" name="t2">
    <input type="button" name="button" value="go" style="cursor:hand;"
    onclick="show(this.form)">
    </form
      

  2.   

    microyzy,你好像误解了我的意思。其实在form里还有很多的文本框要后面都有一个按钮,每个按钮都要调用show()函数,传递的参数是文本框的ID。因为很多的按钮都要调用这个函数,而“t1”是作参数传递的,所以在函数中不能出现document.all.t2.value=document.all.t2.value+a.t1.value中的t1。
    <script language=javascript>
    function show(a){
    document.all.t2.value=document.all.t2.value+document.all.a.value}
    </script>
    <form name="form1" method="post" action="">
    t1:<input type="text" id="t1">
    t2:<input type="text" id="t2">
    <input type="button" name="button" value="go" style="cursor:hand;"
    onclick="show(t1)">
    t3:<input type="text" id="t3">
    <input type="button" name="button" value="go" style="cursor:hand;"
    onclick="show(t3)">t4:<input type="text" id="t3">
    <input type="button" name="button" value="go" style="cursor:hand;"
    onclick="show(t4)"></form>
      
      

  3.   

    <script language=javascript>
    function show(a){
    document.all.t2.value=document.all.t2.value+a.value}
    </script>
    <form name="form1" method="post" action="">
    t1:<input type="text" id="t1">
    t2:<input type="text" id="t2">
    <input type="button" name="button" value="go" style="cursor:hand;"
    onclick="show(this)">
    </form>
      

  4.   

    net_lover,你也误解我的意思了,我要传的是t1、t3、t4……的value值,不是button的value值。