Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > submit opener form after submitting pop-up form

Reply
Thread Tools

submit opener form after submitting pop-up form

 
 
Marco Alting
Guest
Posts: n/a
 
      10-30-2003
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?



 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      10-30-2003
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
 
Reply With Quote
 
 
 
 
Marco Alting
Guest
Posts: n/a
 
      10-30-2003
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" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
Marco Alting
Guest
Posts: n/a
 
      10-30-2003
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" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      10-30-2003
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.
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      10-30-2003
Thomas 'Ingrid' Lahn wrote:

> P.S.
> Your way of intendation is IMHO not suited for legible code.

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


PointedEars
 
Reply With Quote
 
Marco Alting
Guest
Posts: n/a
 
      10-30-2003
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" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> Thomas 'Ingrid' Lahn wrote:
>
> > P.S.
> > Your way of intendation is IMHO not suited for legible code.

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



 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      10-30-2003
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing Popup After Submit to opener Tyrone Slothrop Javascript 1 12-15-2006 09:56 PM
window.opener, form.opener? jojowebdev@gmail.com Javascript 5 07-14-2006 07:08 PM
opener.opener ? Yaron C. Javascript 4 11-02-2003 06:11 AM
Submitting a form without clicking submit Fox ASP General 2 09-10-2003 05:51 PM
trigger event on opener from popup when closing it or run opener script from popup Urs Gubler Javascript 0 07-02-2003 02:08 PM



Advertisments