[英]transfer associated values from popup to parent window jsp/Javascript
I have a popup window with data in a table from database and I am able to transfer the values from the popup to parent window like this: 我有一个弹出窗口,其中有来自数据库的表中的数据,并且能够将值从弹出窗口传输到父窗口,如下所示:
popup data: 弹出数据:
<%
for (int i = 0; i < size; i++) {
ArrayList one = (ArrayList) all.get(i);
%>
<tr style="height:30px; padding:4px;">
<td><div align="center"><a href="" onclick="getBranchValue(this)" id="cname"><%=(String) one.get(0)%></a></div></td>
<td><div align="center"><%=(String) one.get(1)%></div></td>
<td><div align="center"><%=(String) one.get(2)%></div></td>
</tr>
<% }%>
getBranchValue javascript: getBranchValue javascript:
function getBranchValue(ths) {
if (window.opener !== null && !window.opener.closed) {
var func = window.opener.document.getElementById("solid");
func.value = ths.innerHTML; //for innerhtml
window.close();
}
}
I need also to Transfer data in the second array to the parent window so I have Modified by table to: 我还需要将第二个数组中的数据传输到父窗口,因此我已按表将其修改为:
<a href="" onclick="getBranchValue(this,<%=(String) one.get(1)%>)" id="cname">
and my function to: 和我的职能:
function getBranchValue(ths, soldesc) {
if (window.opener !== null && !window.opener.closed) {
var func = window.opener.document.getElementById("solid");
var desc = window.opener.document.getElementById("branchname");
func.value = ths.innerHTML; //for innerhtml
desc.value = soldesc;
window.close();
}
}
But on click it just hangs in there. 但是点击它就挂在那里。 What should I do? 我该怎么办?
I think you must edit code like this: 我认为您必须编辑如下代码:
<a href="" onclick="getBranchValue(this,'<%=(String) one.get(1)%>')" id="cname">
(using single quotation on string parameter that must be passed to JS function) (在必须传递给JS函数的字符串参数上使用单引号)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.