'Submit the form on the parent page of the popup window
The pageA.php is the parent page, pageB.php is the popup window which will display after clicking link on the parent page (i.e. pageA.php).
I would like to close the popup window after clicking submit button on the popup window and the form on the parent page is also submitted at the same time.
The code at below isn't submitting the form on the parent page:
if (isset($_POST['submit'])) {
echo "<script type='text/javascript'>
window.close();
opener.location.formName.submit();
</script>";
}
Is there anyone can help me out?
Solution 1:[1]
- close the window after submitting the form
- use the id for parent form and instead of
opener.location... syntax useopener.document.getElementById('parentformid').submit();
Solution 2:[2]
try and close the child window after submitting the parent.You might be loosing the child handler after parent close.see if helps.
Solution 3:[3]
opener.location.formName isn't a valid way to refer to the form. Try assigning an ID to the form, then using opener.document.getElementById('id').submit();, or opener.document.forms[0].submit();, instead.
You may also need to close the window after submitting the form, rather than before.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | OM The Eternity |
| Solution 2 | Rahul Mathur |
| Solution 3 | Anthony Grist |
