submit opener form after submitting pop-up form

M

Marco Alting

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?
 
T

Thomas 'PointedEars' Lahn

Marco said:
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
 
M

Marco Alting

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.search.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 said:
Marco said:
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
 
M

Marco Alting

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.search.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 said:
Marco said:
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
 
T

Thomas 'PointedEars' Lahn

Marco said:
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.
 
T

Thomas 'PointedEars' Lahn

Thomas said:
P.S.
Your way of intendation is IMHO not suited for legible code.
^^^^^^^^^^^
Typo. Of course `indentation' was meant.


PointedEars
 
M

Marco Alting

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
 
T

Thomas 'PointedEars' Lahn

Marco said:
[...]
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top