justAnoob Posted December 16, 2009 Share Posted December 16, 2009 i have window.open open a window letting the user know that something is going on when the submit button is clicked. The script takes about 10 seconds to run. I am having problems getting the window to close after the PHP script is finished. Any input would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
justAnoob Posted December 16, 2009 Author Share Posted December 16, 2009 sorry, wrong section. Quote Link to comment Share on other sites More sharing options...
gergy008 Posted December 16, 2009 Share Posted December 16, 2009 No it isn't, At the end of the script just echo some javascript code to close the window. Â Unfortunatly, I don't know javascript. Quote Link to comment Share on other sites More sharing options...
justAnoob Posted December 17, 2009 Author Share Posted December 17, 2009 Am I able to call a javascript function before the script is ran, and then after the script is done, run another js function?  ex: <?php js function     before running script script stuff here js function     after script is finished ?>  If this gets to off topic, I have this posted in the js section also. I just wanted to give gergy008 a response. Sorry for the double post. Let me know if I have to close this one down. Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted December 17, 2009 Share Posted December 17, 2009 Yes this is the wrong section, as this is a javascript problem, but you are probably looking for something along the lines of window.close(); Â look it up on google. Although, I think if you try to close the main browsing window, it will throw a message. Why do you want to close the browser anyways? Quote Link to comment Share on other sites More sharing options...
justAnoob Posted December 17, 2009 Author Share Posted December 17, 2009 i'm not looking to close the browser or the main page the user is on. Here it is again. the user goes to an upload page, they hit submit to upload, a popup window displays letting them know that something is happening, when the script is done uploading they are taken to a new page and the popup window is to be closed. it is just the popup window that I want to open before the script and then close after the script. I have searched everywhere on google and cannot find a way to do this. And ok, i'll continue this is js section Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted December 17, 2009 Share Posted December 17, 2009 You don't need to have a popup. Most browser block them anyway... Â The JavaScript: function upload(formdiv, messagediv){ var formID = document.getElementById(formdiv); var messID = document.getElementById(messagediv); formID.style.display = 'none'; messID.style.display = 'block'; } Â The HTML: <div id="form"> <form action="post_somewhere.php" method="post" enctype="multipart/form-data"> <p><label for="file">File:</label> <input type="file" name="somename" id="file" /></p> <p><input type="submit" value="Submit!" onclick="upload('form', 'message');" /></p> </form> </div> <div id="message" style="display:none;"> <h1>Uploading...</h1> <p> Please wait, your file is uploading. Do NOT refresh the page, the page will refresh on it's own. Larger files will take longer to upload, please be patient. </p> <p> Thanks! </p> </div> Quote Link to comment Share on other sites More sharing options...
justAnoob Posted December 17, 2009 Author Share Posted December 17, 2009 That is the way that I originally had the page setup. But I also have some validation that is done before the upload. Right now, with the setup you suggested, when the user hits the submit button and has something wrong filled out, the please wait div still pops up. Quote Link to comment Share on other sites More sharing options...
justAnoob Posted December 17, 2009 Author Share Posted December 17, 2009 I need to call the function inside of the upload script file, and the javascript needs to be ran before the php script so the message is displayed for the user while they are waiting. So is there something I could do inside of the PHP upload script to display the wait message? Quote Link to comment Share on other sites More sharing options...
justAnoob Posted December 18, 2009 Author Share Posted December 18, 2009 at the beginning of my script I tried something like this. echo "<script type='text/javacript'> function upload(message_box) { var messID = document.getElementById(message_box); messID.style.display = 'block'; } upload(message_box); </script>"; But nothing happens. Quote Link to comment 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.