Pass value from child to parent window

We can pass values from a child window in Html to the parent window.

Pass value from child to parent window


Java example program to pass value from child window to parent window

We can pass values from a child window in Html to the parent window. This can be done very easily. Here is the program that takes the value from the child window and then pass it to the parent window. To explain this example we have made two HTML files as follows:

  1. Parent.html : It calls the child window for taking the input value that will be further passed to the parent window and parent window also displays the passed value.
  2. child.html : This the child widow which will be open when we open it from the parent window and will take the value to pass it on to the parent window.

Here is the code for both of the HTML files as follows:


Parent Window
<form method=post name="form">
<table border=0 cellpadding=0 cellspacing=0 width=550>
<font size=2>Show Text</font>
<input type="text" name='parent_name' size='8'>
<a href="javascript:void(0);" name="newWindow" title="Child Window" 
Open child window


<script langauge="javascript">
   function post_value(){
   opener.document.form.parent_name.value =  document.frm.child_name.value;
<title>Child Window</title>

<form name="frm" method=post action=''>
<table border=0 cellpadding=0 cellspacing=0 width=250>
<td align="center">
Input Text :
<input type="text" name="child_name" size=12>
<input type="button" value="Submit" onclick="post_value();">

When we will run the parent file it will look like this:

By clicking on the link "Open Child window" link will open child window as

Here we have to insert or input text which is to be passed to the parent window.

Click on the submit button.

Here is the full code of both files. You can download it.

Download Code


Share on Google+Share on Google+

Pass value from child to parent window

Posted on: May 23, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Pass value from child to parent window   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
July 5, 2011

November 24, 2011
I need java basics

plz send anyone ...
December 20, 2011

January 26, 2012
Pass value from child to parent window

Hi your code is working perfect, but when i try to get more than one value in the text box, it shows "undefined". my text box containg "file one.doc, file_2.xls, file_3.ppt" could you please help to solve this? Thanks Regards Kadher
Pay Sik Kok
February 4, 2012
College Project

It's a reference in the world of programming.
April 2, 2012
javascript and php

javascript and php
April 9, 2012

Good is one
December 22, 2012
java Script

Was very useful useful. But download link is not active I was searching for popUP in java script where it could calculate some values and bring it back to parent window whenever I ckicked on a button in parent window.