469,353 Members | 2,066 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,353 developers. It's quick & easy.

submit opener form after submitting pop-up form

Hi,

I want to use the submit button of a new window to submit the form of the
new window (which carries two values to the opener window) and then submit
the opener form.

Can anyone tell me how to do this?

Jul 20 '05 #1
7 12240
Marco Alting wrote:
I want to use the submit button of a new window to submit the form of the
new window (which carries two values to the opener window) and then submit
the opener form.

Can anyone tell me how to do this?


In the document of the new window:

<form ...
onsubmit="window.setTimeout('opener.document.forms[...].submit()', 42);
return true;"> <!-- one line recommended -->

YMMV
PointedEars
Jul 20 '05 #2
It doesn't seem to work, the onsubmit in the pop-up has a function to it
called setOpener(this), which sends values to variables in the opener form,
after that it should submit the opener form, but it doesn't. Here's the
setOpener function:

function setOpener(oForm) {
if (opener && !opener.closed) {
var recordNo =
self.location.search.substring(1,self.location.sea rch.length);
var opener_form = opener.document.forms[0];
if (opener_form){
var chNo = eval('opener_form.changeNumber' + recordNo);
chNo.value = oForm.chNo.value;
var chDesc = eval('opener_form.changeDescription' + recordNo);
chDesc.value = oForm.chDesc.value;
}
self.close();
window.setTimeout('opener.document.forms[0].checkForm()', 42);
return true;
}
}
"Thomas 'PointedEars' Lahn" <Po*********@web.de> schreef in bericht
news:3F************@PointedEars.de...
Marco Alting wrote:
I want to use the submit button of a new window to submit the form of the new window (which carries two values to the opener window) and then submit the opener form.

Can anyone tell me how to do this?


In the document of the new window:

<form ...
onsubmit="window.setTimeout('opener.document.forms[...].submit()', 42);
return true;"> <!-- one line recommended -->

YMMV
PointedEars

Jul 20 '05 #3
It doesn't seem to work, the onsubmit in the pop-up has a function to it
called setOpener(this), which sends values to variables in the opener form,
after that it should submit the opener form, but it doesn't. Here's the
setOpener function:

function setOpener(oForm) {
if (opener && !opener.closed) {
var recordNo =
self.location.search.substring(1,self.location.sea rch.length);
var opener_form = opener.document.forms[0];
if (opener_form){
var chNo = eval('opener_form.changeNumber' + recordNo);
chNo.value = oForm.chNo.value;
var chDesc = eval('opener_form.changeDescription' + recordNo);
chDesc.value = oForm.chDesc.value;
}
self.close();
window.setTimeout('opener.document.forms[0].checkForm()', 42);
return true;
}
}
"Thomas 'PointedEars' Lahn" <Po*********@web.de> schreef in bericht
news:3F************@PointedEars.de...
Marco Alting wrote:
I want to use the submit button of a new window to submit the form of the new window (which carries two values to the opener window) and then submit the opener form.

Can anyone tell me how to do this?


In the document of the new window:

<form ...
onsubmit="window.setTimeout('opener.document.forms[...].submit()', 42);
return true;"> <!-- one line recommended -->

YMMV
PointedEars

Jul 20 '05 #4
Marco Alting wrote:
It doesn't seem to work, [...]
self.close();
window.setTimeout('opener.document.forms[0].checkForm()', 42);


`self' is in fact a reference to the same object as `window' is. Once
a window is closed, no further statements of its code can be executed.
Exchange the two lines and it should work (if `checkForm()' actually
submits the opener form.) YMMV for the number of milliseconds to wait
until the opener form should be submitted (here: 42.)
HTH

PointedEars

P.S.
Your way of intendation is IMHO not suited for legible code.
(Most important: Don't use tabs but spaces since the former's
width depends on the display device.)

P.P.S.
Please read http://www.allmyfaqs.com/faq.pl?How_to_post about
top-posts.
Jul 20 '05 #5
Thomas 'Ingrid' Lahn wrote:
P.S.
Your way of intendation is IMHO not suited for legible code.

^^^^^^^^^^^
Typo. Of course `indentation' was meant.
PointedEars
Jul 20 '05 #6
Ofcourse you're right, when a window is closed it cannot perform any action,
but now I've changed the lines around and now the pop-up doesn't close and
the opener is not submitted...

Any more ideas?

Thanks,
M

"Thomas 'PointedEars' Lahn" <Po*********@web.de> schreef in bericht
news:3F**************@PointedEars.de...
Thomas 'Ingrid' Lahn wrote:
P.S.
Your way of intendation is IMHO not suited for legible code.

^^^^^^^^^^^
Typo. Of course `indentation' was meant.
PointedEars

Jul 20 '05 #7
Marco Alting wrote:
[...]
but now I've changed the lines around and now the pop-up doesn't close and
the opener is not submitted...

Any more ideas?
Have you tried to adjust the milliseconds for timeout?
What error messages do you get (in the JavaScript console)?
[...]


Please reply only to the postings you are referring to,
and please put the quote shortened to the text you are
actually referring to *above* your text, not below it:

http://www.allmyfaqs.com/faq.pl?How_to_post
http://www.netmeister.org/news/learn2quote2.html
PointedEars
Jul 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Yaron C. | last post: by
2 posts views Thread by Raphael Bowen Giudice | last post: by
16 posts views Thread by John | last post: by
1 post views Thread by Ray Slakinski | last post: by
4 posts views Thread by Gabriella | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.