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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.