Hi, I'm trying to open a popup page after my form is submitted, however when i place my window.open code after the form.submit code it will not open the window, like so:
<script language="JavaScript">
function confirmation(f){
if (confirm('Are you sure you want to enter $'+form1.NewMoney.value+' to Account #: '+form1.AccountNumber.value+'? Click "OK" to add money or "CANCEL" to change something')) {
f.submit();
window.open ('/reseller/beepers4less/receipt.php');
}
else {
return false }
}
</script>
when i place the window.open before the f.submit() it will open the window and then submit the form, however, i need the form to be submitted first and then open the window because it passes info to the new page through php sessions, and with the window opening first the page will come up empty...
anyone know why this happens this way?
Thanks in advance. :)
Beagle
03-16-2006, 11:13 PM
submit sends a request, which forces the current page to unload in preparation for the response. This means that right after the submit, subsequent code does not get executed.
You might want to look into using XMLHTTPRequests to submit the form asynchoronously and then open the window.
You could also open the window on the action page of the form, so if the form submits to pagey.php, make pagey.php open the new window.
pita0017
03-16-2006, 11:39 PM
Alright, so now i did this and im not getting a popup. Not sure why it's not working, probably did something wrong, my java sucks, sorry...:(
<SCRIPT LANGUAGE="JavaScript">
function popup(URL) {
window.open(URL,'Receipt');
}
</script>
<form action="<?php echo $editFormAction; ?>" method="POST" OnSubmit="return formValidation(this) && formValidation2(this) && confirmation(this) && popup('/reseller/beepers4less/receipt.php')" name="form1">
thanks for your help beagle.
trendybox
03-17-2006, 03:44 PM
function popup(URL) {
window.open(URL,'Receipt');
}
Where do you call the function popup and what gets passed into it as the URL variable?
why does everyone call javascript "java" aren't they two completely different languages?