求教传值问题

cakexiang 2009-06-24 03:08:19
希望得到这么一个效果:
从父窗口弹出一子窗口用来显示可供选择的信息,在选择了子窗口信息提交后关闭子窗口并将所选信息返回给父窗口显示出来。
...全文
80 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
宇晨007 2009-06-30
  • 打赏
  • 举报
回复
onclick="set();"
function set()
{
window.close();
parent.document.getElementById('fsdfads').value='';
}
还是这个简单明了
xuelang0725 2009-06-30
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 cakexiang 的回复:]
引用 4 楼 xuelang0725 的回复:
javascript就可以了


请大家给个简单示范啊,谢谢。
[/Quote]
看六楼兄弟的回复
window.opener.document.getElementById("productID"+sRowId).value
|
父窗体的
= window.document.getElementById("productID"+SelectRow).value;
|
子窗体的

作用就是将子窗体上的某一控件的值赋给父窗体上的某一控件
这段代码是写在子窗体中的。。。。。。
jim8590251 2009-06-30
  • 打赏
  • 举报
回复
用JS parent不就好了?
onclick="set();"
function set()
{
window.close();
parent.document.getElementById('fsdfads').value='';
}
cakexiang 2009-06-30
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 cenzige 的回复:]
用两个页面做:
fathe.php
<?php
echo $_GET['tex'];
?>
<script type="text/javascript">

window.open("son.html","name","height=300,width=400");
</script>

son.html
<html>
<head>
<title>子窗口 </title>
<script type="text/javascript">
function f1_submit(){

window.close("name");
}
</script>
</head>

<body>
<form name="f1" action="test.php">
<input name="tex" type="text">
<inp…
[/Quote]
不好意思前段时间有事。
我用你的方法还是不行啊,form的方法用POST或get都不行。
php.ini也改了register_globals = On
cakexiang 2009-06-30
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 jakey9826 的回复:]
HTML code//test2.html<divid='test'style='width:200px;height:200px;border:1pxsolid red;'></div><inputtype='button'onclick='window.open("test3.html");'value='open'>//test3.html<scriptlanguage='javascript'>functionsave()
{vartmp=document.getElementById("ttt");
window.opener.document.getElementById("test").innerHTML=tmp.value;
window.close();
}</script><inputtype='text'id='ttt'va…
[/Quote]

简单明了且成功运行,谢谢!
程序猿之殇 2009-06-30
  • 打赏
  • 举报
回复
//test2.html
<div id='test' style='width:200px;height:200px;border:1px solid red;'></div>
<input type='button' onclick='window.open("test3.html");' value='open'>
//test3.html
<script language='javascript'>
function save()
{
var tmp = document.getElementById("ttt");
window.opener.document.getElementById("test").innerHTML = tmp.value;
window.close();
}
</script>
<input type='text' id='ttt' value='' name='ttt'/>
<input type='button' onclick='save();' value='save'>


cakexiang 2009-06-30
  • 打赏
  • 举报
回复
??
cakexiang 2009-06-30
  • 打赏
  • 举报
回复
没调出来,能否发一个完整的例子,谢谢各位。
岑子哥 2009-06-24
  • 打赏
  • 举报
回复
用两个页面做:
fathe.php
<?php
echo $_GET['tex'];
?>
<script type="text/javascript">

window.open("son.html","name","height=300,width=400");
</script>

son.html
<html>
<head>
<title>子窗口</title>
<script type="text/javascript">
function f1_submit(){

window.close("name");
}
</script>
</head>

<body>
<form name="f1" action="test.php">
<input name="tex" type="text">
<input type="button" value="提 交" onClick="f1_submit()">
</form>
</body>
</html>
tfxg 2009-06-24
  • 打赏
  • 举报
回复
照抄的,自己整理下
tfxg 2009-06-24
  • 打赏
  • 举报
回复
product.php
<a href='Javascript: SelectProduct(1);' class='blue'>

function SelectProduct(SelectRow)
{
var sRowId=document.all.rowId.value;
window.opener.document.getElementById("productID"+sRowId).value
=window.document.getElementById("productID"+SelectRow).value;
window.opener.document.getElementById("ItemCode"+sRowId).value
=window.document.getElementById("TypeName"+SelectRow).value;
window.opener.document.getElementById("ProductCode"+sRowId).value
=window.document.getElementById("ProductCode"+SelectRow).value;
window.opener.document.getElementById("Description"+sRowId).value
=window.document.getElementById("BrandName"+SelectRow).value
+" "+window.document.getElementById("TypeName"+SelectRow).value
+" "+window.document.getElementById("ModelNo"+SelectRow).value
+" "+window.document.getElementById("ProductCode"+SelectRow).value;;
window.opener.document.getElementById("UnitPrice"+sRowId).value
=window.document.getElementById("NewPrice"+SelectRow).value;
//window.close();
window.location.href="productvendorlist.php?rowId="+sRowId+"&productID="
+window.document.getElementById("productID"+SelectRow).value;
}


productvendorlist.php

<td valign='center' align='center'><A Href='Javascript: SelectVendor("11"); '>Select</td>

function SelectVendor(SelectRow)
{
var sRowId=document.all.rowId.value;
window.opener.document.getElementById("cost"+sRowId).value
=window.document.getElementById("NewCost"+SelectRow).value;
window.close();
}
cakexiang 2009-06-24
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 xuelang0725 的回复:]
javascript就可以了
[/Quote]

请大家给个简单示范啊,谢谢。
xuelang0725 2009-06-24
  • 打赏
  • 举报
回复
javascript就可以了
tfxg 2009-06-24
  • 打赏
  • 举报
回复
ajax
其實基本的js也能實現
cakexiang 2009-06-24
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 simonhehe 的回复:]
使用Ajax就可以了
[/Quote]

请问有AJAX推荐学习资料吗?
simonhehe 2009-06-24
  • 打赏
  • 举报
回复
使用Ajax就可以了

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧