Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Pass variable to parent window and update the form filed

Reply
Thread Tools

Pass variable to parent window and update the form filed

 
 
umashd@yahoo.com
Guest
Posts: n/a
 
      06-17-2005
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>

 
Reply With Quote
 
 
 
 
Jc
Guest
Posts: n/a
 
      06-17-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Question
> 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:
http://www.jibbering.com/faq/#FAQ4_13

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:
http://msdn.microsoft.com/library/de...es/value_1.asp

 
Reply With Quote
 
 
 
 
umashd@yahoo.com
Guest
Posts: n/a
 
      06-17-2005
Hi JC

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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Any DR filed for 5.1.2.2.1.1: Implementation dependent form of main? null hypothesis C Programming 1 09-06-2010 08:57 PM
If a class Child inherits from Parent, how to implementChild.some_method if Parent.some_method() returns Parent instance ? metal Python 8 10-30-2009 10:31 AM
setting form values via external js file ... trying to use document.form.filed.value jason@cyberpine.com Javascript 3 11-08-2004 02:05 PM
Pass from parent to child, then update parent with child value... Noel Dolan Javascript 0 07-18-2004 05:52 PM
dynamic generate form filed Jorntk Javascript 2 04-23-2004 03:14 PM



Advertisments