我在A页面有一个文本框和一个按钮,我想点击按钮以后,弹出一个窗口B页面,B页面是一个表格,点击表格的一行,把表格当前行的第一个单元格的值传到A页面的文本框内。可以实现A页面无刷新吗?请帮忙,谢谢
解决方案 »
- 什么做出来的报表能添加事件??在线等。。。。。。。。。。。
- 我想实现这样一种效果,各位大侠来帮下忙!!
- 关于<a href="#" onclick="">
- JS出错问题
- 菜鸟问题,去掉粗体
- 为何将xmlHttp.responseXML.documentElement传进函数后无法用dom解析?
- 在js中,如果将一个数字转为二进制?
- 公司要我做相册 没做过啊~ 大家提醒下有什么技巧 一下搞定的~或者有代码 干脆复制一下
- 请问各位谁有现成的javascript的脚本,就是广告乱飞的那种+++急+++急+++急
- 行行好,帮一下。关于javascript中showModalDialog的小问题
- 求解决浏览器兼容问题
- 弹出层效果
A.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>A</title>
<script type="text/javascript">
function setTextValue(val){
document.getElementById("test").value = val;
}
</script>
</head><body>
<input type="text" id="test" />
<input type="button" value="取值" onclick="window.open('B.html','b','');" />
</body>
</html>
B.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>B</title>
<script type="text/javascript">
function setValue(obj){
var val = obj.innerHTML;
window.opener.setTextValue(val);
}
</script>
</head><body>
<table >
<tr><td onclick="setValue(this);">第一列</td><td onclick="setValue(this);">第二列</td></tr>
</table>
</body>
</html>
A.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>A</title>
<script type="text/javascript">
function setTextValue(val){
document.getElementById("test").value = val;
}
</script>
</head><body>
<input type="text" id="test" />
<input type="button" value="取值" onclick="window.open('B.html','b','');" />
</body>
</html>
B.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>B</title>
<script type="text/javascript">
function setValue(obj){
var val = obj.innerHTML;
window.opener.setTextValue(val);
}
</script>
</head><body>
<table >
<tr><td onclick="setValue(this);">第一列</td><td onclick="setValue(this);">第二列</td></tr>
</table>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>a.html</title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head> <body>
<h3>a.html</h3>
<input type="text" id="txtInput" /><input type="button" id="btnOpen" value="Open B" />
<script type="text/javascript">
<!--
var oBtn = document.getElementById("btnOpen");
oBtn.onclick = function() {
window.showModelessDialog("b.html", window);
};
//-->
</script>
</body>
</html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>b.html</title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head> <body>
<h3>b.html</h3>
<table id="tabTest" border="1">
<tr>
<td>1</td>
<td>a</td>
<td>b</td>
</tr>
<tr>
<td>2</td>
<td>c</td>
<td>d</td>
</tr>
<tr>
<td>3</td>
<td>e</td>
<td>f</td>
</tr>
</table>
<script type="text/javascript">
<!--var parentWin = window.dialogArguments;
var oTxt = parentWin.document.getElementById("txtInput");var oTab = document.getElementById("tabTest");
for (var i=0; i<oTab.rows.length; i++)
{
oTab.rows[i].onclick = function() {
oTxt.value = this.cells[0].innerHTML;
this.style.cursor = "hand";
};
} //-->
</script>
</body>
</html>
<body>
<input type="input" id="show" name="show" /> <input type="button" id="btn" name="btn" value="点击" onclick="window.open('b.html')" />
</body>
</html>B 页面代码:
<table border="1" onclick="getrow(this)">
<tr>
<td>a1</td>
<td>a2</td>
</tr>
<tr>
<td>b1</td>
<td>b2</td>
</tr>
</table><script>
// 为表格 tr 添加事件
function getrow(obj)
{
if(event.srcElement.tagName=="TD"){
curRow=event.srcElement.parentElement;
window.opener.document.getElementById('show').value = curRow.cells[0].innerText;
}
}</script>
其他需求,可以参照例子来修改。
如果你用showModelsDialog打开的窗口,就用dialogArguments得到父窗体对象!