1、123.php 中,<input type=text name=aaa>的值,就是收到传来的值
____________是否测试过,能不能收到?
2、<form action="456.html">这里为什么是html文件,下面你所列456.php
是不是你的这个456.html
先看看这两个问题,
____________是否测试过,能不能收到?
2、<form action="456.html">这里为什么是html文件,下面你所列456.php
是不是你的这个456.html
先看看这两个问题,
<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!
应该是上边的456.php
因为:
<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了!
<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()
} 好了,成功了!
我必须加上动态取值,否则就没用了。
你教教我呀?该如何解呀!!!
那个$i没有定义呀!!
<? while($r=mssql_fetch_array($result)) {?>
之前加$i=0;
每循环一次$i++;
这样就可以了。
<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>用这个试试看,我没试过的
"<input type=\"text\" name=\"friendname[$r[t_friendno]]\" value=\"$r[t_friendname]\">
这个数组在php中可以处理,在javascript中好象不行,而且如果$r[t_friendno]不唯一就麻烦了。
请指教。
除了你说的$r[t_friendno]不唯一是个问题外,其他我想应该不是问题。
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>好用就说一声
我马上去抄!!!
全给出来了,望您指点!!!
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>
window.opener.document.scsp.t4.value=bbb.friendname[index].value
要改为
window.opener.document.scsp.t4.value=rep.friendname[index].value你太粗心了