M.O.S. Studios Posted January 15, 2009 Share Posted January 15, 2009 hey guys i want a window to close after the submit button has been hit any one know it? Link to comment https://forums.phpfreaks.com/topic/140950-solved-fast-question-about-closing-a-window/ Share on other sites More sharing options...
rhodesa Posted January 15, 2009 Share Posted January 15, 2009 window.close() but the window must be opened by window.open() or else it will prompt the user if they are sure they want to close it Link to comment https://forums.phpfreaks.com/topic/140950-solved-fast-question-about-closing-a-window/#findComment-737745 Share on other sites More sharing options...
M.O.S. Studios Posted January 15, 2009 Author Share Posted January 15, 2009 it didn't work this is my code <html> <head> <script type="text/javascript"> function sendToPageOne() { var thisValue = document.getElementById('image1').value; window.opener.form1.image1.value = thisValue; } </script> </head> <body> <form name="form2" onsubmit="window.close()";> <select name="image1" id="image1"> <option value="one">One</option> <option value="Two">Two</option> <option value="Three">Three</option> </select> </form> <input type="submit" onclick="sendToPageOne()"; value="Send to page 1"> </body> </html> it was opened with this code <br><a href="javascript:popUp('content/products/browse.php?name=image2')"><font size="1">Browse</font></a><input type="text" name="image2" value="" readonly> Link to comment https://forums.phpfreaks.com/topic/140950-solved-fast-question-about-closing-a-window/#findComment-737751 Share on other sites More sharing options...
rhodesa Posted January 15, 2009 Share Posted January 15, 2009 sorry...it's just close() Link to comment https://forums.phpfreaks.com/topic/140950-solved-fast-question-about-closing-a-window/#findComment-737761 Share on other sites More sharing options...
M.O.S. Studios Posted January 15, 2009 Author Share Posted January 15, 2009 Hey still no luck i have tried self.close() close() and window.close() maybe im putting it in wrong this is what i did <form name="form2" onsubmit="self.close()"> Link to comment https://forums.phpfreaks.com/topic/140950-solved-fast-question-about-closing-a-window/#findComment-737768 Share on other sites More sharing options...
rhodesa Posted January 15, 2009 Share Posted January 15, 2009 try <html> <head> <script type="text/javascript"> function sendToPageOne() { var thisValue = document.getElementById('image1').value; window.opener.form1.image1.value = thisValue; close(); } </script> </head> <body> <select name="image1" id="image1"> <option value="one">One</option> <option value="Two">Two</option> <option value="Three">Three</option> </select> <input type="button" onclick="sendToPageOne()"; value="Send to page 1"> </body> </html> Link to comment https://forums.phpfreaks.com/topic/140950-solved-fast-question-about-closing-a-window/#findComment-737775 Share on other sites More sharing options...
M.O.S. Studios Posted January 15, 2009 Author Share Posted January 15, 2009 looking at what you did that would probably work aswell, how ever i just did this and it works perfectly <html> <head> <script type="text/javascript"> function sendToPageOne() { var thisValue = document.getElementById('<?php echo $_GET['name'] ?>').value; window.opener.form1.<?php echo $_GET['name'] ?>.value = thisValue; } </script> </head> <body> <form name="form2" action="browse.php" method="POST"> <select name="<?php echo $_GET['name'] ?>" id="<?php echo $_GET['name'] ?>"> <option value="one">One</option> <option value="Two">Two</option> <option value="Three">Three</option> </select> <input type="hidden" name="sent" value="1"> </form> <input type="submit" onclick="sendToPageOne();self.close();"; value="Send to page 1"> </body> </html> Link to comment https://forums.phpfreaks.com/topic/140950-solved-fast-question-about-closing-a-window/#findComment-737777 Share on other sites More sharing options...
M.O.S. Studios Posted January 15, 2009 Author Share Posted January 15, 2009 Thanks for all the help Link to comment https://forums.phpfreaks.com/topic/140950-solved-fast-question-about-closing-a-window/#findComment-737778 Share on other sites More sharing options...
shlumph Posted January 15, 2009 Share Posted January 15, 2009 What if they think it's a bug, and try and keep submiting the form, and say "God damnit, how come it keeps closing when I hit submit!!!"? Link to comment https://forums.phpfreaks.com/topic/140950-solved-fast-question-about-closing-a-window/#findComment-737782 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.