CTalkobt.Net




Programming Newsgroup Tips & Tricks CubeCart Stuff
Subject: Pass variable to parent window and update the form filed
From: umashd@yahoo.com
Date: 17 Jun 2005 10:18:50 -0700
Newsgroups: comp.lang.javascript
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Path: bigbe1.bellsouth.net!bigfeed.bellsouth.net!news.bellsouth.net!news.glorb.com!postnews.google.com!g44g2000cwa.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Organization: http://groups.google.com
Lines: 109
Message-ID: <1119028730.082258.271510@g44g2000cwa.googlegroups.com>
NNTP-Posting-Host: 202.156.2.210
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1119028736 22643 127.0.0.1 (17 Jun 2005 17:18:56 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 17 Jun 2005 17:18:56 +0000 (UTC)
User-Agent: G2/0.2
Complaints-To: groups-abuse@google.com
Injection-Info: g44g2000cwa.googlegroups.com; posting-host=202.156.2.210; posting-account=Z1VIGgwAAAAtc8Bd9eXKTcTcf0rj3n9v
Xref: bigfeed.bellsouth.net comp.lang.javascript:571624

Hi,

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

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.

Question
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 ===============
<HTML>
<HEAD>
<TITLE>Open New Window</TITLE>

<SCRIPT LANGUAGE="JavaScript">
function showvar () {
document.write("<BR><BR>");
document.write("Value of variable parentvar is " + parentvar +".");
document.write("<BR><BR>");
}
</SCRIPT>

</HEAD>
<BODY>


<SCRIPT LANGUAGE="JavaScript">
var parentvar = "Parent";
document.write("Value of variable parentvar is " + parentvar +".");
document.write("<BR><BR>");
</SCRIPT>




<FORM ACTION="temp.html" METHOD="POST">
<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) ">
</FORM>

</BODY>
</HTML>


==== Code from POPUP.HTML =============


<HTML>
<HEAD>
<TITLE>Pop Up Window</TITLE>

<SCRIPT LANGUAGE="JavaScript">

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

</SCRIPT>

</HEAD>

<BODY>



<form method="POST" action="submitted.html" name="Newform">


<table border="0" cellpadding="0" width="550" id="table1">
<tr>
<td width="340" align="left"><font
color="#FF0000">parentvar</font></td>
<td width="10">&nbsp;</td>
<td width="200"><input type="text" name="parentvar" size="30"
tabindex="1"></td>
</tr>
</table>
<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()"> ->
</FORM> 
	

</BODY> 
</HTML>