Javascript 弹出窗口值未反映在父窗口中
我试图在父窗口的文本框中获取弹出窗口的值。但它不起作用。有人能帮忙吗 Parent.jspJavascript 弹出窗口值未反映在父窗口中,javascript,jsp,Javascript,Jsp,我试图在父窗口的文本框中获取弹出窗口的值。但它不起作用。有人能帮忙吗 Parent.jsp <style> a:hover, a:active { background-color:red ; } </style> <form action="FirstTest" method="post" id="TestForm"> <input type="text" id="PrintHere"/ ><br><br>
<style>
a:hover, a:active {
background-color:red ;
}
</style>
<form action="FirstTest" method="post" id="TestForm">
<input type="text" id="PrintHere"/ ><br><br>
<a target="_blank" onclick="SelectName('POST')"> Repository Link </a>
</form>
<script type="text/javascript">
function SelectName(methodType) {
var win=window.open("Popup.jsp", "thePopUp", "width=300,height=100, left=24, top=24, scrollbars, resizable");
win.focus();
}
</script>
Popup.jsp
<form id="PopUpForm">
<input type="text" id="ddlNames"> <br /> <br />
<input type="button" value="Select" onclick="SetName();" />
</form>
<script type="text/javascript">
function SetName() {
if ((window.opener != null) && !(window.opener.closed)) {
var Textvalue;
Textvalue.value = document.getElementById("ddlNames").value;
var TextBox = window.opener.document.getElementById("PrintHere");
TextBox.value = Textvalue.value
}
window.close();
} </script>
<form id="PopUpForm">
<input type="text" id="ddlNames"> <br /> <br />
<input type="button" value="Select" onclick="SetName();" />
</form>
<script type="text/javascript">
function SetName() {
if ((window.opener != null) && !(window.opener.closed)) {
var TextBox = window.opener.document.getElementById("PrintHere");
TextBox.value = document.getElementById("ddlNames").value;
}
window.close();
}
</script>
在Popup.jsp上更改代码,如下所示
<form id="PopUpForm">
<input type="text" id="ddlNames"> <br /> <br />
<input type="button" value="Select" onclick="SetName();" />
</form>
<script type="text/javascript">
function SetName() {
if ((window.opener != null) && !(window.opener.closed)) {
var TextBox = window.opener.document.getElementById("PrintHere");
TextBox.value = document.getElementById("ddlNames").value;
}
window.close();
}
</script>
你的问题不清楚。只需给5分钟时间添加代码。添加代码时出现应用程序错误。请检查答案上的工作示例。感谢GUISSOUMA Issam