473,382 Members | 1,348 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

window.opener HELP!!

I have a normal window cotaining a form (named form1). The form has a text
input called imageURL. There is a button that, when clicked, opens a new
window that contains three frames (left, right and bottom.) In the right
frame is another form (named form2) with a hidden input (selected). When
form2 is submitted, I want the value of selected to be passed back to the
imageURL on form1 and then close.

The code I have tried is as follows:

(From my frame...)
<SCRIPT language="JavaScript">
function passValues()
{
// pass variable back to parent window
window.opener.document.form1.imageURL.value =
document.form2.selected.value;
}
top.window.close();
</SCRIPT>

It closes just fine, but imageURL on form1 never changes.

Anyone with ideas on how to make this work is encouraged to offer their
help!!
Jul 23 '05 #1
3 6525
ctrl+alt+delete wrote:
In the right frame is another form (named form2) with a
hidden input (selected). When form2 is submitted, I want the value of
selected to be passed back to the imageURL on form1 and then close.
[...]
// pass variable back to parent window
window.opener.document.form1.imageURL.value =
document.form2.selected.value;


The opener opened the frameset's top window, not the frame your statement
is in. So you want to use top.opener... instead of window.opener... here.
In addition, since the popup is not modal, you should avoid error
messages caused by an already closed opener window (or by having another
document in the opener already) by testing if the used properties and
objects are still available:

var oOpener, oOpenerForm, oOpenerElement;
if (
(oOpener = top.opener)
&& !oOpener.closed
&& (oOpenerForm = top.opener.document.forms["form1"])
&& (oOpenerElement = oOpenerForm.elements["imageURL"])
) {
oOpenerElement.value
= document.forms["form2"].elements["selected"].value;
}

This looks a little laborious compared to waht you had, but it's
essential to avoid error messages.

ciao, dhgm
Jul 23 '05 #2
Hey, thanks a lot for the quick reply! I will try out what you suggested and
post my results.

"Dietmar Meier" <us***************@innoline-systemtechnik.de> wrote in
message news:36*************@individual.net...
ctrl+alt+delete wrote:
In the right frame is another form (named form2) with a
hidden input (selected). When form2 is submitted, I want the value of
selected to be passed back to the imageURL on form1 and then close.
[...]
// pass variable back to parent window
window.opener.document.form1.imageURL.value =
document.form2.selected.value;


The opener opened the frameset's top window, not the frame your statement
is in. So you want to use top.opener... instead of window.opener... here.
In addition, since the popup is not modal, you should avoid error
messages caused by an already closed opener window (or by having another
document in the opener already) by testing if the used properties and
objects are still available:

var oOpener, oOpenerForm, oOpenerElement;
if (
(oOpener = top.opener)
&& !oOpener.closed
&& (oOpenerForm = top.opener.document.forms["form1"])
&& (oOpenerElement = oOpenerForm.elements["imageURL"])
) {
oOpenerElement.value
= document.forms["form2"].elements["selected"].value;
}

This looks a little laborious compared to waht you had, but it's
essential to avoid error messages.

ciao, dhgm

Jul 23 '05 #3
Here's what I ended up going with and it works perfectly:

top.window.opener.document.forms["form1"].elements["imageURL"].value =
"#Form.selected#";

Note: I am processing this script on a ColdFusion page, hence the use of
#Form.selected#.

Thanks again for the help. I wasn't sure how to reference the input back on
my original page.
"Dietmar Meier" <us***************@innoline-systemtechnik.de> wrote in
message news:36*************@individual.net...
ctrl+alt+delete wrote:
In the right frame is another form (named form2) with a
hidden input (selected). When form2 is submitted, I want the value of
selected to be passed back to the imageURL on form1 and then close.
[...]
// pass variable back to parent window
window.opener.document.form1.imageURL.value =
document.form2.selected.value;


The opener opened the frameset's top window, not the frame your statement
is in. So you want to use top.opener... instead of window.opener... here.
In addition, since the popup is not modal, you should avoid error
messages caused by an already closed opener window (or by having another
document in the opener already) by testing if the used properties and
objects are still available:

var oOpener, oOpenerForm, oOpenerElement;
if (
(oOpener = top.opener)
&& !oOpener.closed
&& (oOpenerForm = top.opener.document.forms["form1"])
&& (oOpenerElement = oOpenerForm.elements["imageURL"])
) {
oOpenerElement.value
= document.forms["form2"].elements["selected"].value;
}

This looks a little laborious compared to waht you had, but it's
essential to avoid error messages.

ciao, dhgm

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: fogwolf | last post by:
First a basic outline of what I am trying to do: I want to have a page spawn a pop-up when you click "submit" on its form. On this pop-up page there will be another form. When you click "submit"...
1
by: ian.michel | last post by:
I have a parent window that pushes a new window object onto an Array with the following code : OpenChild() { //totalNumWindowsCreated is global totalNumWindowsCreated =...
19
by: Darren | last post by:
I have a page that opens a popup window and within the window, some databse info is submitted and the window closes. It then refreshes the original window using window.opener.location.reload(). ...
2
by: RWC | last post by:
Hello, I am new to JavaScript but until now, have felt my way along fairly successfully. I have a page showing an image to the user. I use window.open to open a separate page, listing a bunch...
4
by: Phil Powell | last post by:
I thought this would work but it seems to not work neither in Netscape nor in IE: <script type="text/javascript"> <!-- // OBTAINED FROM http://www.javascripter.net/faq/settinga.htm //...
5
by: asadhkhan | last post by:
I have the following code which works correctly in IE 6, but in IE 7, Fire Fox 2.0 and Netscape 8 it does not work. I have a main page where a button calls this pop-up and uploads a file once you...
1
by: Vexander | last post by:
Hi I am trying to right a script that closes a popup and then refreshes the pener to specific URL If have this that works form me <script type="text/javascript"> ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.