Gossamer Forum
Home : General : Internet Technologies :

Passing value from one Browser Window to another.

Quote Reply
Passing value from one Browser Window to another.
I have a following in browser window one -

<label for="school"> <strong>School: </strong> </label> <input type="text" name="School" id="School" maxlength="75" size="20" value="" >
<i> <a href="/cgi-bin/listschools.cgi " target="_blank" >Select School</a></i>


User can click on Select School link to get a list of all school. Listschools.cgi opens a new browser window two, ask for the 'state" and after that list all the Schools in that state city-wise in following format -

Princeton, Princeton HS
Palo Alto, Palo Alto HS

User clicks on school name say Palo Alto HS to select it, the browser window closes on click, and passes the value "Palo Alto HS" to the window one to populate School textbox.

I would appreciate if someone can help me in writing this properly to accomplish value passing using Javascript or any other technic.

Thanks.

TIF

Last edited by:

TIF: Apr 4, 2010, 12:29 PM
Quote Reply
Re: [TIF] Passing value from one Browser Window to another. In reply to
You would really need to use a javascript new.window() to open the URL to the script. Then, when you want to return the value - you would do something like:
Code:
opener.document.formname.field.value = "something"

Heres a good example - hopefully will get you on the right tracks:

http://www.rgagnon.com/jsdetails/js-0066.html

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Passing value from one Browser Window to another. In reply to
Thanks for your reply Andy. I should have reported back earlier, but I am still struggling to make it work. The example you gave works.

Here is what I tried based on the example-

First window -

<SCRIPT LANGUAGE="JavaScript">
function openChild(file,window) {
childWindow=open(file,window,'resizable=yes,width=400,height=600,scrollbars=1');
if (childWindow.opener == null) childWindow.opener = self;
}
</SCRIPT>



<FORM NAME="parentForm">
<input type="text" name="School" id="School" maxlength="75" size="20" value=<%if School%>"<%School%>"<%endif%> > &nbsp; &nbsp; <a href=# onClick="openChild('getschool.cgi','win2')">Select School</a>

<br><INPUT TYPE="button" VALUE="Select School" onClick="openChild('getschool.cgi','win2')">
</FORM>


When you click on the link or the button, it works - the child window open.


=============================================================================

The child windows has following code -

print " <SCRIPT LANGUAGE=JavaScript> \n";
print "function updateParent(schl) {\n";
print " alert(schl); \n";
print " opener.document.parentForm.School.value = schl; \n";
print " self.close(); return False; \n";
print " } \n";
print " </SCRIPT> \n";



and the code that print the list of city, schools is -

while (my $ref = $sth->fetchrow_hashref()) {
print "<tr><td width=25%><font face=Arial style=font-size:10pt; > $ref->{'City'} </td><td><i> <a href=# onClick=\"return updateParent($ref->{'Name'});\" > $ref->{'Name'} </a></i>
</font> </td></tr> \n";
}


The child window comes up but sits there for some reason when I click on the links, and does not pass the value or close.

I am trying to make it work. let me know if you see any problems. Or any suggestion to make it work.

Thanks.

Last edited by:

TIF: Apr 6, 2010, 8:25 PM
Quote Reply
Re: [TIF] Passing value from one Browser Window to another. In reply to
You got an example of where I can see it running?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [TIF] Passing value from one Browser Window to another. In reply to
Thanks Andy. It is working using the same code.

The opener.document.parentForm.School.value was coming null or undefined as I had a form inside a form, so it was not getting resolved. Once I sorted that out, it worked like a charm.

Thanks again.

TIF