Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get value from popup window to parent window by clicking from database selection?

Status
Not open for further replies.

bach1

Technical User
Sep 26, 2019
1
CZ
Originally it was like this and it worked until the crawlers no longer supported it, and even the return No. after the click I got there:

<scriptlanguage="JavaScript"type="text/javascript">var retVal=""var valReturned;function openModal(){
retVal=showModalDialog('stranky/modal.php');
valReturned=retVal;
document.getElementById("zakaznik").value=valReturned;}</script>


<td><inputid="zakaznik"type="text"name="zakaznik"value="'.$_POST["zakaznik"].'">&nbsp;<inputclass="odeslat"type="button"name="vybrat"value="Vybrat"onClick="openModal()"></td>

In the modal window it clicked only this way and it worked and it works even in the historical version of the web browser to this day, but new browsers do not open it anymore:

<td><ahref="#"onclick="returnValue='.$data["id"].';window.close();">'.$data["id"].'</a></td>

Unfortunately, I can not modify it to work in new browsers, and therefore please advice: just click on a value and it transferred and the window clicked the value itself closed.

So I wanted to modify it somehow and use this:

<scriptlanguage="JavaScript"type="text/javascript">
var retVal=""
var valReturned;
function openModal() {
retVal = window.open("stranky/modal.php", "_blank", "width=950,height=600");
valReturned=retVal;
document.getElementById("zakaznik").value=valReturned;
//alert('The following text has been returned: "'+valReturned+'"');
}

<tr><td>Zákazník:</td><td><inputid="zakaznik"type="text"name="zakaznik"value="">&nbsp;<inputclass="odeslat"type="button"name="vybrat"value="Vybrat"onclick="openModal()"></td></tr>

in popup window (modal.php) I have this:

<td><ahref="#"onclick="returnValue='.$data["id"].';window.close();">'.$data["id"].'</a></td>

window will open to me normally, I can click on the selected value from the database - after clicking on the selected field will close the window, but the form field zakaznik in the parent window does not get the value, only when opening the popup window will form [object Window] zakaznik. I think I miss something, and I think it's wrong. could someone advise what it should look like? Thank you.

 
 https://files.engineering.com/getfile.aspx?folder=4148d961-7ee6-4fd4-a2e7-709fb505277e&file=vvv.PNG
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top