Jump to content

Parent window/Child window


dream25

Recommended Posts

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 :)

Link to comment
https://forums.phpfreaks.com/topic/95736-parent-windowchild-window/
Share on other sites

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

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>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.