dream25 Posted March 12, 2008 Share Posted March 12, 2008 Hi folk... I have a parent window with one text field and open button, if i click the open button, the child window has open,in that child window,one text field and one submit button, lets type the text in the field and click submit,then the text can be display in the parent text field, the value can be pass by php code, is it possible to do this script, will u plz help me out, if u have any code, plz forward it.. Thanks in Advance, Shree Uday Quote Link to comment Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 I think Ajax would be your best shot, I have done this before, I basically had the PHP file send the data from the child window to the parent window and it would come up in a "live" update. -------------- ---------------------------------------------------------------------------------------- Child Window | ------ PHP $_POST -------> | AJAX Checks The php File for New Posted Data, using setTimeout() to re run the process ---------------------------------------------------------------------------------------- | | Show the Posted Data Quote Link to comment Share on other sites More sharing options...
dream25 Posted March 12, 2008 Author Share Posted March 12, 2008 here i attached my code, plz check it.. Index.php <?php print_r($_POST); ?> <html> <script language='javascript' type="text/javascript"> function open_win() { window.open('child.php'); } </script> <body> <form name='frm_parent'> <input type='text' name='txt_parent' value=''> Hello Test <input type='button' value="Click Here" onclick=open_win()> </body> </html> child.php <html> <head> <script language='javascript' type="text/javascript"> </script> </head> <body> <form name='child_form' method='post' action='index1.php'> Enter Your Text <input type='text' name='txt_childtext'/> <input type='submit' value='Submit'name='submit'/> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
dream25 Posted March 12, 2008 Author Share Posted March 12, 2008 Is it possible the pass thePHP value.. when we pass the text from child window to parent window... thanks in Advance.. Shree Uday Quote Link to comment Share on other sites More sharing options...
phpSensei Posted March 12, 2008 Share Posted March 12, 2008 Sorry, I went to sleep early last night, so here is my reply... Basically what you can do is create an XMlHttpRequest Object and then make 3 functions... - function 1 will open the PHP file (The same file Where in the Child windows Form the action is set to) - function 2 will handle the XMlHttpRequest's data that is given back by the PHP file - function 3 will repeat function 1 each 1 second (without refreshing the page) to check if the value of the PHP file is changed, hence someone typing something different in the child window. All this means is that when you open the child window and you post data to lets say "handlePost.php", then that will echo what you posted, but this echo will not be shown to you on the handlePost.php, it will shown on the parent window doing or making the functions or steps I showed you. Its a little complicated, so you need to start reading about some ajax. Quote Link to comment Share on other sites More sharing options...
dream25 Posted March 13, 2008 Author Share Posted March 13, 2008 Thank u.. Surely i will try to implement the code... Shree Uday 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.