Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
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.html

<html>
<head>
<title>
Parent Window
</title>
</head>
<body>
<form method=post name="form">
<table border=0 cellpadding=0 cellspacing=0 width=550>
<tr>
<td>
<font size=2>Show Text</font>
<input type="text" name='parent_name' size='8'>
<a href="javascript:void(0);" name="newWindow" title="Child Window" 
  onClick="window.open('child.html','newWindow','width=550,
  height=170,left=150,top=200,toolbar=no,resizable=false')">
Open child window
</a>
</td>
</tr>
</table>
</form> 
</body>
</html>

child.html

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

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

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

                         

» View all related tutorials
Related Tags: java c jsp script io ip page vi value js to e ls can from in pass as m ca

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.