1、123.php 中,<input type=text name=aaa>的值,就是收到传来的值
____________是否测试过,能不能收到?
2、<form action="456.html">这里为什么是html文件,下面你所列456.php
是不是你的这个456.html
先看看这两个问题,

解决方案 »

  1.   

    abc.php
    <html>
    <body>
    <form name=scsp>
    <input type=text name="t4" value="" onkeydown="if(event.keyCode==13){window.open('123.php?'+this.value,'report');}">
    </form>
    </body>
    </html>123.php
    <html>
    <head>
    <script>
    window.onload=function() {
    var arr=window.location.search.split("?")
    if(arr.length>1)
    document.all.aaa.value=arr[1];
    }
    </script>
    </head>
    <body>
    <form action="456.php">
    <input type=text name=aaa>
    <input type=submit name=send value="send">
    </form>
    </body>
    </html>456.php
    <html>
    <head>
    <script>
    function lw() {
    window.opener.document.scsp.t4.value=bbb.friendname.value
    window.close()
    }
    </script>
    </head>
    <body>
    <form name="bbb">
    <input type="button" name="friendno" value="id" onclick="lw()">
    <input type="text" name="friendname" value="test">
    </form>
    </body>
    </html>我用上面试了一下,NO PROBLEM!
      

  2.   

    从abc.php传过去的值肯定能收到。戏子哥您可以把我的abc.php和123.php立即改为:abc.html 和123.html做测试的。<form action="456.html">是我输入错误!
    应该是上边的456.php
      

  3.   

    phpteam(George)大哥:我所做的与你告之的有一点不一样,
    因为:
    <input type="button" name="friendno" value="id" onclick="lw()">
    <input type="text" name="friendname" value="test">
    是动态取的值,如 我上边456.php中所写的这一段:
    <? $id=mssql_connect('server','sa'); 
    $db=mssql_select_db('db1'); 
    $query="select t_friendno,T_friendname from bodyinfo where T_pyfriendname" like '$aaa'"; 
    $result=mssql_query($query); 
    ?> 
    <table><tr><th>序号</th><th>姓名</th></tr> 
    <? while($r=mssql_fetch_array($result)) {?> 
    <form name="bbb"> 
    <tr><td> 
    <input type="button" name="friendno" value="<? echo $r[t_friendno];?>" onclick="lw()"> 
    </td> 
    <td><input type="text" name="friendname" value="<? echo $r[t_friendname];?>"></td></tr> 
    <? } ?> 
    是需要根据:$aaa的值动态变化而变化的呀!
    你告诉我的,我也试了,能成功。可一换动态取值,又还是变成underfined了!
      

  4.   

    问题就出在动态这块,你想想,这么多动态的东西,可名字取的都是一样的:friendno、friendname,我想问题应该就在这里吧!
      

  5.   

    我试了下,如果数据返回一条记录是不会错的,但返回多条记录时,肯定会出错的,因为你在456.php中的bbb.friendname是个数组,所以你的lw()应该带个index参数,这个参数由php产生,即
    <input type="button" name="friendno" value="<? echo $r[t_friendno];?>" onclick="lw()"> 
    改为
    <input type="button" name="friendno" value="<? echo $r[t_friendno];?>" onclick="lw(<? echo $i;?>)"> 然后把
    function lw() { 
    window.opener.document.scsp.t4.value=bbb.friendname[1].value 
    window.close() 

    改为
    function lw(index) { 
    window.opener.document.scsp.t4.value=bbb.friendname[index].value 
    window.close() 
    } 好了,成功了!
      

  6.   

    phpteam(George)哥:
    我必须加上动态取值,否则就没用了。
    你教教我呀?该如何解呀!!!
      

  7.   

    binscut(binscut):
    那个$i没有定义呀!!
      

  8.   

    你在456.php中的
    <? while($r=mssql_fetch_array($result)) {?> 
    之前加$i=0;
    每循环一次$i++;
    这样就可以了。
      

  9.   

    <html>
    <head>
    <script>
    function lw(index) {
    window.opener.document.scsp.t4.value=bbb.friendname[index].value
    window.close()
    }
    </script>
    </head>
    <body>
    <table>
    <tr><th>序号</th><th>姓名</th></tr>
    <form name="bbb">
    <?php
    $id=mssql_connect('server','sa');
    $db=mssql_select_db('db1');
    $query="select t_friendno,T_friendname from bodyinfo where T_pyfriendname like '$aaa'";
    $result=mssql_query($query);
    while($r=mssql_fetch_array($result))
    {
      echo "<tr>";
      echo "<td>";
      echo "<input type=\"button\" name=\"friendno\" value=\"$r[t_friendno]\" onclick=\"lw('$r[t_friendno]')\">";
      echo "</td>";
      echo "<td>";
      echo "<input type=\"text\" name=\"friendname[$r[t_friendno]]\" value=\"$r[t_friendname]\">";
      echo "</td>";
      echo "</tr>";
    }
    ?>
    </form>
    </table>
    </body>
    </html>用这个试试看,我没试过的
      

  10.   

    在javascript中处理的数组名是不能加[]号的, phpteam(George) 兄的
    "<input type=\"text\" name=\"friendname[$r[t_friendno]]\" value=\"$r[t_friendname]\">
    这个数组在php中可以处理,在javascript中好象不行,而且如果$r[t_friendno]不唯一就麻烦了。
    请指教。
      

  11.   

    TO binscut(binscut):
      除了你说的$r[t_friendno]不唯一是个问题外,其他我想应该不是问题。
      

  12.   

    算了,还是帮你改了吧,反正现在没事干。
    456.php 
    <html> 
    <head> 
    <script> 
    function lw(index) { 
    window.opener.document.scsp.t4.value=bbb.friendname[index].value 
    window.close() 

    </script> 
    </head> 
    <body> 
    <? $id=mssql_connect('server','sa'); 
    $db=mssql_select_db('db1'); 
    $query="select t_friendno,T_friendname from bodyinfo where T_pyfriendname" like '$aaa'"; 
    $result=mssql_query($query); 
    $i=0;
    ?> 
    <table><tr><th>序号</th><th>姓名</th></tr> 
    <? while($r=mssql_fetch_array($result)) {?> 
    <form name="bbb"> 
    <tr><td> 
    <input type="button" name="friendno" value="<? echo $r[t_friendno];?>" onclick="lw(<?PHP echo $i;?>)"> 
    </td> 
    <td><input type="text" name="friendname" value="<? echo $r[t_friendname];?>"></td></tr> 
    <? 
    $i++;
    }
    ?> 
    </table></form></body></html>好用就说一声
      

  13.   

    binscut(binscut)兄:你给我的改动我去试了!IE给我报了个错:window.opener.document.scsp.t4.value 为空或不是对象!!!
      

  14.   

    奇怪,这个地方我没有改你的,怎么你原来又没出这错误,是不是你的abc.php改了?把abc.php和456.php贴出来看看?
      

  15.   

    binscut(binscut) 哥您等到我!!!
    我马上去抄!!!
      

  16.   

    binscut(binscut)兄:
    全给出来了,望您指点!!!
    abc.php全文如下:
    <html><head><script>
    function closed() {
    self.close()
    }
    function printed() {
    window.print()
    }
    </script></head>
    <?
    $today=date("Y年m月d日");
    ?>
    <body onkeydown="if(event.keyCode==13)event.keyCode=9;">
    <form name=scsp>
    <p align="center" style="line-height:1%"><b>朋友登录</b></p>
    <table> 
    <tr>
    <td><p>城市:<input type="text" name="t1" tabindex="1"></p></td>
    </tr></table>
    <table><tr><td>您的姓名</tr>
    <tr><td><input type="text" name="t4" onkeydown="if(event.keyCode==13){window.open('123.php?'+this.value,'report');}">
    </td></tr></table><p>
    <input type="button" name="print" value="打印" onclick="printed()">
    <input type="button" name="close" value="退出" onclick="closed()">
    </p></form></body></html>123.php
    <html>
    <head>
    <script>
    window.onload=function() {
    var arr=window.location.search.split("?")
    if(arr.length>1)
    document.all.aaa.value=arr[1];
    }
    </script>
    </head>
    <body>
    <form action="456.php">
    <input type=text name=aaa>
    <input type=submit name=send value="send">
    </form>
    </body>
    </html>
    <我的456.php全文如下:
    <html><head>
    <script>
    function lw(index) {
    window.opener.document.scsp.t4.value=bbb.friendname[index].value
    window.close()
    }
    </script></head>
    <body>
    <? 
    $id=mssql_connect('server','sa');
    $db=mssql_select_db('db1');
    $query="select t_friendno,t_friendname from bodyinfo where t_pyfriendname like '$aaa'";
    $result=mssql_query($query);
    $i=0;
    ?>
    <table border=1 width=900>
    <tr bgcorlor="#c8e3ff">
    <th>编号</th>
    <th>姓名</th>
    </tr>
    <?
    $h=mssql_num_rows($result);
    echo("检索到:");
    echo($h);
    echo("位名称类似的朋友");
    while($r=mssql_fetch_array($result)) { ?>
    <form name=rep>
    <tr><td><input type="button" name="friendno" value="<? echo $r[t_friendno];?>" onclick="lw(<?PHP echo $i;?>)"> 
    </td> 
    <td><input type="text" name="friendname" value="<? echo $r[t_friendname];?>"></td></tr> 
    <?
    $i++;}
    ?>
    </table></form></body></html>
      

  17.   

    你看456.php中的form,name已经变为rep了,所以
    window.opener.document.scsp.t4.value=bbb.friendname[index].value
    要改为
    window.opener.document.scsp.t4.value=rep.friendname[index].value你太粗心了