472,142 Members | 1,276 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,142 software developers and data experts.

Pass variable to parent window and update the form filed


I am doing a web based project for my graduation. I studied bit of java
for backend processesing and javascript for the client. Here is the

In the FORM, I use INPUT TYPE=text VALUE=" " NAME=cat, and a gif next
to it. User will click on the icon to get a new window. In the new
window, the user selects a value from the pull down menu (created by
servlet from back end) and clicks OK. The value is passed back to the
opener window to variable cat. Upto this point my code works. I can see
that the variable cat changes.

How can I display the values of these variables into the fields of form
which is already loaded? May be a simple one, but me being a beginner,
I am stuck for more than 24 hours. Please help. My project dead line is
just three days away.

Thanks in advance.

Here is the test code (knowledge gained from internet) I have written
for this task.

=== Code in OPENERWINDOW.HTML ===============
<TITLE>Open New Window</TITLE>

function showvar () {
document.write("Value of variable parentvar is " + parentvar +".");

var parentvar = "Parent";
document.write("Value of variable parentvar is " + parentvar +".");

<div id="Parent_var" class="FieldText"> </div> <INPUT TYPE="text"
id="Parent_var" NAME="parentvar" VALUE="Parent">
<INPUT TYPE="Button" VALUE="Get value from New Window" NAME="popup"
onClick="window.open('popup.html') ">
<INPUT TYPE="Button" VALUE="Next" NAME="returned" onClick="showvar
(parentvar) ">

==== Code from POPUP.HTML =============
<TITLE>Pop Up Window</TITLE>


function sendVar (parentvar) {
document.write (" <BR><BR> Current Value of parentvar is " + parentvar
+ ".");
opener.parentvar = parentvar;




<form method="POST" action="submitted.html" name="Newform">
<table border="0" cellpadding="0" width="550" id="table1">
<td width="340" align="left"><font
<td width="10">&nbsp;</td>
<td width="200"><input type="text" name="parentvar" size="30"
<INPUT TYPE="Button" VALUE="Send to Parent Window" NAME="Click"
onClick="sendVar (parentvar.value)">
<! <INPUT TYPE="Button" VALUE="Close Window" NAME="closwin"
onClick="self.close()"> ->

Jul 23 '05 #1
2 9119
um****@yahoo.com wrote:
How can I display the values of these variables into the fields of form
which is already loaded?

The FAQ for this group may be of help:

You can dynamically change properties of HTML elements even after the
page has loaded through javascript. For example, you want to change the
value property of a form element:

Jul 23 '05 #2

That was really help on time. I should have applied my mind more on
reading rather than codeing. I added
document.forms.newWindow.parentvar.value=parentvar . That worked. Thanks
a lot.

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by cksj | last post: by
6 posts views Thread by mkobus | last post: by
1 post views Thread by Bill Borg | last post: by
14 posts views Thread by =?Utf-8?B?Umljaw==?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.