By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 1,983 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

submit opener form after submitting pop-up form

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.