robert_gsfame Posted December 6, 2010 Share Posted December 6, 2010 How can i pass value to parent window? Let say page1.php <input type="button" value="open window" onclick="javascript:window.open('page2.php')"> <div id="test"></div> page2.php <input type="button" value="close window" onclick="passvalue('HELLO WORLD')"> so what should be written in function passvalue() so that the words "HELLO WORLD" shown up in <div id="test"></div>?? what i've tried so far in confusion and not working is this function passvalue(x) { window.parent.document.getElementById("test").innerHTML=x; window.close(); } thx for any help Quote Link to comment https://forums.phpfreaks.com/topic/220825-pass-value-to-parent-window/ Share on other sites More sharing options...
brianlange Posted December 6, 2010 Share Posted December 6, 2010 The parent window should be referred to as "opener" function passvalue(x) { window.opener.document.getElementById("test").innerHTML=x; window.close(); } Here's a working example using your code: http://www.realtown.com/test5.php Quote Link to comment https://forums.phpfreaks.com/topic/220825-pass-value-to-parent-window/#findComment-1143652 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.