Lodius2000 Posted October 25, 2008 Share Posted October 25, 2008 in php i have a form, when you submit the form php runs a function called process form, that does the necesary queries and such and now i need to close the window (since it is a popup aside from the main cms window and has done its purpose) so heres what im coming up with process forms does the queries, then a new form is made that auto submits and closes the window, like so <?php process_form(){ //do queries //ok heres what i have print ' <html> <head> <script language="javascript"> function autoSubmit() { document.form.submit(); } </script> </head> <body> <form name="close" method="POST" action="'.htmlentities($_SERVER['PHP_SELF']).'?id=' . $id . '"> <input type="hidden" name="_submit_check1" value="1" /> <input type=button value="Close This Window" onClick="javascript:window.close();"> <script language="JavaScript"> if (`_submit_check1`) { autoSubmit(); } </script> </body> </html>'; } ?> so this makes a button called Close This Window as i would expect it to do but it doesnt auto submit (that i can tell) because clicking the button does close the window also, I know pretty much zero javascript, so this it patched together from the internet and to me, it doenst look like it should work, which indeed it doesnt, but i dont know what i have to do to fix it, so help please Quote Link to comment https://forums.phpfreaks.com/topic/130021-help-me-close-a-popup/ Share on other sites More sharing options...
BoltZ Posted October 25, 2008 Share Posted October 25, 2008 Well I see a couple errors with this. Put the <script> tags in the head section. Another one is to not have <script language="javascript">. That is the depreciated way of doing it. Use <script type="text/javascript">. Try that stuff then tell me how it goes. Also no one really uses print anymore. Try echo but I don't think that would really help the output. Quote Link to comment https://forums.phpfreaks.com/topic/130021-help-me-close-a-popup/#findComment-674145 Share on other sites More sharing options...
Lodius2000 Posted October 25, 2008 Author Share Posted October 25, 2008 ok now its <html> <head> <script type="text/javascript"> function autoSubmit() { document.form.submit(); } </script> </head> <body> <form name="close" method="POST" action="'.htmlentities($_SERVER['PHP_SELF']).'?id=' . $id . '"> <input type="hidden" name="_submit_check1" value="1" /> <input type=button value="Close This Window" onClick="javascript:window.close();"> <script type="text/javascript"> if (`_submit_check1`) { autoSubmit(); } </script> </body> </html> and im getting the same results Quote Link to comment https://forums.phpfreaks.com/topic/130021-help-me-close-a-popup/#findComment-674154 Share on other sites More sharing options...
BoltZ Posted October 25, 2008 Share Posted October 25, 2008 is the function autosubmit the php processing function? If so you have that in javascript script tags. You need to encase it with <?php ?> tag and take it out of the javascript tags. Can you post a link to your site which this is happening? Quote Link to comment https://forums.phpfreaks.com/topic/130021-help-me-close-a-popup/#findComment-674300 Share on other sites More sharing options...
Lodius2000 Posted October 26, 2008 Author Share Posted October 26, 2008 autosubmit() is a js function, php does not have the capability to close a window Quote Link to comment https://forums.phpfreaks.com/topic/130021-help-me-close-a-popup/#findComment-675174 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.