Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 弹出窗口值未反映在父窗口中_Javascript_Jsp - Fatal编程技术网

Javascript 弹出窗口值未反映在父窗口中

Javascript 弹出窗口值未反映在父窗口中,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>

我试图在父窗口的文本框中获取弹出窗口的值。但它不起作用。有人能帮忙吗

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>
   <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