请教在一个JS弹出层上,双击某行给父页面文本框赋值的问题

bopirate 2012-12-13 03:07:43
父页面上用JS弹出层(所谓的百度弹出登陆框的那个)弹出一个子页面 url ,在这个子页面上双击表格某行,就给父页面的表单文本框赋值,同时弹出层关闭,达到规范用户输入的目的。赋值这一块搞不定,请高手帮忙:
演示页面:http://pic.zttit.com/FloatLayer/
代码打包:http://pic.zttit.com/FloatLayer/FloatLayer.rar
...全文
346 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
成都诚信 2013-11-12
  • 打赏
  • 举报
回复
我下载下来之后 下载后双击无反应呢!在您测试的网址上有效果 什么情况呢
JW森 2012-12-13
  • 打赏
  • 举报
回复
chrom中不能实现 只支持ie index添加如下方法

<script>
	function setData(name, jiguan, age){
	    document.getElementById('textfield1').value = name;
        document.getElementById('textfield2').value = jiguan;
        document.getElementById('textfield3').value =age;
	}
</script>
url中添加如下方法:

<script>
	function test(name, jiguan, age){
		parent.setData(name, jiguan, age);
		parent.g_close_pop();
	}
</script>
url中html代码改成如下形式:

 <tr onDblClick="test('张三', '美国', '12')">
bopirate 2012-12-13
  • 打赏
  • 举报
回复
谢谢版主大大出手。
  • 打赏
  • 举报
回复
关闭窗口放到最后执行,要不关闭层后移除了DOM对象,再进行其他操作就报错了 url.htm
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<style type="text/css">
<!--
body {
	font-size: 12px;
	margin: 40px;
	line-height: 24px;
}
table  { border-collapse: collapse; }
td {
	border: #ccc 1px solid;
	line-height:22px;
}
th{
	line-height: 28px;
	background-color: #eee;
	border: #ccc 1px solid;
}
-->
</style>
<script>
    function setData(name, addr, age) {
        var doc = parent.document;
        doc.getElementById('textfield1').value = name;
        doc.getElementById('textfield2').value = addr;
        doc.getElementById('textfield3').value =age;
    }
</script>
</head>
<body>
此页面文件名为 url.htm ,双击表格行,将值赋给刚才的表单,同时弹出层关闭。<br />
<table width="400" align="center" cellpadding="0" cellspacing="0" >
  <tr>
    <th align="center"><strong>姓名</strong></th>
    <th align="center"><strong>籍贯</strong></th>
    <th align="center"><strong>年龄</strong></th>
  </tr>
  <tr onDblClick="javascript:setData('张三','美国','12');parent.g_close_pop();">
    <td align="center">张三</td>
    <td align="center">美国</td>
    <td align="center">12</td>
  </tr>
  <tr onDblClick="javascript:setData('李四','英国','11');parent.g_close_pop();">
    <td align="center">李四</td>
    <td align="center">英国</td>
    <td align="center">11</td>
  </tr>
  <tr onDblClick="javascript:setData('王五','中国','15');parent.g_close_pop();">
    <td align="center">王五</td>
    <td align="center">中国</td>
    <td align="center">15</td>
  </tr>
</table>
</body>
</html>

87,991

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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