Forum Moderators: open
[i know this sort of thing has been discussed extensively in previous post, but much searching has not turned up quite what im looking for...]
i have a page (lotsofforms.php) with many separate forms (each corresponding to a row in a database) - submission of any particular form is handled by a php script (action.php) which just updates the corresponding db row and redirects back to its caller (lotsofforms.php).
the problem is that every time the user clicks 'submit changes' he/she must wait for the entire page (lotsofforms.php) to reload.
my temporary current solution is to just have a popup confirmation window upon form submission saying the changes have been submitted -- action.php updates the db but does not reload the page (just returns a 204 no content header). the problem with this is that it does not account for errors that occur in action.php...
so what i would like to do is have the form submissions go to action.php as before but IN A NEW POPUP WINDOW. in other words, the user would click 'submit changes' and a small window would popup that would say:
"your changes are being submitted..."
then, form data would be processed (ie updated in the database), and depending on the outcome, the popup window (still loading action.php) would either report an error or say:
"...submission was successful, click here to close this window"
on close, the focus would return to lotsofforms.php which would remain unchanged and would not have been reloaded.
hope i didnt make it sound too much more complicated than it really is...
thanks in advance,
emory
So, you should keep the action and onSubmit attributes of the forms the same, so that it still works the same way for users without JavaScript.
The you can call a JavaScript function from the body onLoad event. The function should rewrite the onSubmit attributes of the forms to something new: they should now call a funtion that will open a new window, then write the new window's content with the form data, then submit it.
You can open the new window like this:
var myWindow = window.open("", "Submitting")
Now you can use the myWindow variable as a reference to the new window, and use it's innerHTML property to write a form into it.
HTH