submit opener form after submitting pop-up form

Discussion in 'Javascript' started by Marco Alting, Oct 30, 2003.

  1. Marco Alting

    Marco Alting Guest

    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?
     
    Marco Alting, Oct 30, 2003
    #1
    1. Advertising

  2. 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
     
    Thomas 'PointedEars' Lahn, Oct 30, 2003
    #2
    1. Advertising

  3. Marco Alting

    Marco Alting Guest

    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" <> schreef in bericht
    news:...
    > 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
     
    Marco Alting, Oct 30, 2003
    #3
  4. Marco Alting

    Marco Alting Guest

    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" <> schreef in bericht
    news:...
    > 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
     
    Marco Alting, Oct 30, 2003
    #4
  5. 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.
     
    Thomas 'PointedEars' Lahn, Oct 30, 2003
    #5
  6. Thomas 'Ingrid' Lahn wrote:

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

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


    PointedEars
     
    Thomas 'PointedEars' Lahn, Oct 30, 2003
    #6
  7. Marco Alting

    Marco Alting Guest

    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" <> schreef in bericht
    news:...
    > Thomas 'Ingrid' Lahn wrote:
    >
    > > P.S.
    > > Your way of intendation is IMHO not suited for legible code.

    > ^^^^^^^^^^^
    > Typo. Of course `indentation' was meant.
    >
    >
    > PointedEars
     
    Marco Alting, Oct 30, 2003
    #7
  8. 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
     
    Thomas 'PointedEars' Lahn, Oct 30, 2003
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fox
    Replies:
    2
    Views:
    277
    Randy Rahbar
    Sep 10, 2003
  2. Urs Gubler
    Replies:
    0
    Views:
    159
    Urs Gubler
    Jul 2, 2003
  3. Yaron C.

    opener.opener ?

    Yaron C., Oct 30, 2003, in forum: Javascript
    Replies:
    4
    Views:
    219
    Yaron C.
    Nov 2, 2003
  4. window.opener, form.opener?

    , Jul 14, 2006, in forum: Javascript
    Replies:
    5
    Views:
    287
  5. Tyrone Slothrop

    Closing Popup After Submit to opener

    Tyrone Slothrop, Dec 15, 2006, in forum: Javascript
    Replies:
    1
    Views:
    235
Loading...

Share This Page