472,805 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 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 6501
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"> ...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{

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.