I’m using php and jquery. I have a form in php, after filling in the form, I wanna be able to click submit and send the data to a modal window pop up, where the form data is displayed. There will be an additional textbox to fill in, then after clicking another submit, this textbox + the form data will be submitted to a processing page on the parent window.
So basically, i dunno how to –
1) Pass form data from form to modal window – do i use json stringify and if so how?
2) How to submit from the modal window the previous form data + data in the textbox back to the original form
Thanks
After opening new window with
window.open(), you can access “parent window” viawindow.opener. E.g., if you have<form id='foo'/>in parent window, you can access it as$(window.opener).find('#foo')from “modal” window.What about sending POST to the same window, validating data, reloading the page and if everything is successful in the first form, then showing modal window after reloading the page? Data could be stored in
$_SESSION, that way you don’t have to worry about passing data between windows. Or, if you really want to pass data to the form of child window, you can do something like this (not tested):someValue1,someValue2,someValue3would be values from$_POST, passed throughjson_encode().