submitting a form through another frame

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • threeflush

    submitting a form through another frame

    I'm supporting an ASP legacy application and need to implement
    "autosave" functionality. I have two frames, one that holds tabs
    displaying different pages a user can select, and the other that holds
    the page content itself. If a user clicks on another tab without
    clicking the Submit button, I want to submit the current form for them
    and do some further processing.
    The problem is that top.framename.f ormname.submit( ) only works
    sporadically. Sometimes the document object of the page frame does not
    exist. Is there any way to "guarantee" that the document object will
    exist?
    Has anyone ever encountered this problem or have any suggestions?

  • Erwin Moller

    #2
    Re: submitting a form through another frame

    threeflush wrote:
    [color=blue]
    > I'm supporting an ASP legacy application and need to implement
    > "autosave" functionality. I have two frames, one that holds tabs
    > displaying different pages a user can select, and the other that holds
    > the page content itself. If a user clicks on another tab without
    > clicking the Submit button, I want to submit the current form for them
    > and do some further processing.
    > The problem is that top.framename.f ormname.submit( ) only works
    > sporadically. Sometimes the document object of the page frame does not
    > exist. Is there any way to "guarantee" that the document object will
    > exist?
    > Has anyone ever encountered this problem or have any suggestions?[/color]

    Hi,

    Try FIRST to submit the form, then to replace the window with new content.
    I guess your setup works sometimes because of raceconditions: Sometimes the
    form is submitted before the whole page is replaced.

    There are several ways to fix this.
    The first thing I would try is to use the onUnload event in the page to do
    the submitting, or at least give a warning.

    I do not have a lot of experience with the onUnload handler. (It was
    erractic when I first examined it, but that was Stoneage)

    If that doesn't help, try to replace the hyperlinks in the frame that
    replaces you formframe with javascript, so are are sure you first submit,
    then replace.
    This however can be a lot of work, depending on the number of hyperlinks.

    By the way: Are that people that DON't submit the form, but demand that you
    save it anyhow, perhaps, IT-managers?
    ('WORD does it, so why doesn't our app do it? Fix that bug please')
    Dilbert?
    Quite an unreasonable request IMHO....

    Anyway, that doesn't help.
    Good luck!

    Regards,
    Erwin Moller

    Comment

    • Paul R

      #3
      Re: submitting a form through another frame

      threeflush wrote:[color=blue]
      > I'm supporting an ASP legacy application and need to implement
      > "autosave" functionality. I have two frames, one that holds tabs
      > displaying different pages a user can select, and the other that holds
      > the page content itself. If a user clicks on another tab without
      > clicking the Submit button, I want to submit the current form for them
      > and do some further processing.
      > The problem is that top.framename.f ormname.submit( ) only works
      > sporadically. Sometimes the document object of the page frame does not
      > exist. Is there any way to "guarantee" that the document object will
      > exist?
      > Has anyone ever encountered this problem or have any suggestions?
      >[/color]
      It sounds like you want to use the standard body unload event instead of
      trying to create a "tab-click" event.

      On the form page: <body onunload="docum ent.forms[0].submit()">

      Is that what you're asking?

      Comment

      • threeflush

        #4
        Re: submitting a form through another frame

        Thanks for replies. I've tried the <body> onunload and onbeforeunload
        events but both have flaws as far as this specification is concerned.
        onunload destroys the form BEFORE I have a chance to submit.
        onbeforeunload has the same sporadic behavior as accessing the submit()
        event from another frame not to mention the fact that it's only
        supported in IE...
        Any other ideas perhaps?

        **gotta love those frames!!!!!**

        Comment

        • Paul R

          #5
          Re: submitting a form through another frame

          threeflush wrote:[color=blue]
          > Thanks for replies. I've tried the <body> onunload and onbeforeunload
          > events but both have flaws as far as this specification is concerned.
          > onunload destroys the form BEFORE I have a chance to submit.
          > onbeforeunload has the same sporadic behavior as accessing the submit()
          > event from another frame not to mention the fact that it's only
          > supported in IE...
          > Any other ideas perhaps?
          >
          > **gotta love those frames!!!!!**
          >[/color]
          I can't reproduce this at all. Have you tried validating your HTML? Any
          chance you could post a (short) misbehaving version of your pages?

          Comment

          • threeflush

            #6
            Re: submitting a form through another frame

            What do you mean by "validating "? I'll post an abridged version
            shortly... Thanks.

            Comment

            • eric

              #7
              Re: submitting a form through another frame

              Sounds like you need to fire functions in a careful order. First no
              matter what tab you click the current 'page content' should be
              "submitted" so when you create the tabs the first thing to do is to do
              this submit --in other words they all do the same thing. Then you can
              do the "tab" function to change the "page content" page. You will then
              have to update the state of the "tab" frame. A very tricky bit of code
              for sure.

              Comment

              • Paul R

                #8
                Re: submitting a form through another frame

                threeflush wrote:[color=blue]
                > What do you mean by "validating "? I'll post an abridged version
                > shortly... Thanks.
                >[/color]
                Using software to confirm that your HTML follows the rules. It's amazing
                how a couple of misplaced HTML tags can wreck some perfectly good
                JavaScript.

                Try http://validator.w3.org/

                Comment

                • threeflush

                  #9
                  Re: submitting a form through another frame

                  Thanks, the validator found sound minor errors so I will correct those
                  and give it another go. I've found that posting an abridged version of
                  the code is too difficult as it's very complex (not my design, I might
                  add!).

                  Comment

                  • threeflush

                    #10
                    Re: submitting a form through another frame

                    So I've found that calling the bottom form's submit() using this
                    javascript:

                    parent.frames[4].document.info. submit();

                    works ONLY if I also include a javascript alert immediately after this
                    line, like such:

                    parent.frames[4].document.info. submit();
                    alert('whatever ');

                    This got me thinking about implementing some sort of delay or sleep
                    function.

                    Does anyone have any idea why it would always work if I "pause" with a
                    javascript alert?

                    Thanks.

                    Comment

                    • trustee

                      #11
                      Re: submitting a form through another frame





                      "threeflush " <david.wray@gma il.com> wrote in message
                      news:1108667059 .249476.238630@ l41g2000cwc.goo glegroups.com.. .[color=blue]
                      > So I've found that calling the bottom form's submit() using this
                      > javascript:
                      >
                      > parent.frames[4].document.info. submit();
                      >
                      > works ONLY if I also include a javascript alert immediately after this
                      > line, like such:
                      >
                      > parent.frames[4].document.info. submit();
                      > alert('whatever ');
                      >
                      > This got me thinking about implementing some sort of delay or sleep
                      > function.
                      >
                      > Does anyone have any idea why it would always work if I "pause" with a
                      > javascript alert?
                      >
                      > Thanks.
                      >[/color]


                      Comment

                      • Varadarajan Seshadri

                        #12
                        Re: submitting a form through another frame

                        I landed here facing the same problem, the submit fires when u give a
                        dummy alert, did u find any way to fix this.

                        varada

                        *** Sent via Developersdex http://www.developersdex.com ***
                        Don't just participate in USENET...get rewarded for it!

                        Comment

                        • threeflush

                          #13
                          Re: submitting a form through another frame

                          Thanks trustee. I'm so glad you're able to take your life's
                          frustrations out on google groups. You make the world a better place.

                          Comment

                          • threeflush

                            #14
                            Re: submitting a form through another frame

                            Varadarajan, I ended up bypassing the need to submit the info by
                            placing the two bits of information in a sesssion (ASP) variable.

                            Comment

                            • Archimedes Trajano

                              #15
                              Re: submitting a form through another frame

                              You can try this... It opens up a new window containing the same form,
                              copy all the data into the new window then click on the submit button.
                              Afterwards close the window.

                              At least this method will support users clicking on the back buttons or
                              bookmarks. You may optimize this to have a flag to check if data was
                              changed and such.

                              Following is a code snippet.

                              <script>
                              function doSubmit() {
                              var submitter = window.open("fo rmsubmit.html") ;
                              submitter.docum ent.getElementB yId("FOOID").va lue =
                              document.getEle mentById("FOOID ").value;
                              submitter.docum ent.getElementB yId("AUTOSAVE") .click();
                              submitter.close ();
                              }
                              </script>


                              <body onunload="doSub mit()">
                              <form action="http://localhost/" method="get">
                              FOO<input type="text" id="FOOID" name="FOO" value="xyz" />
                              <input type="Submit" id="AUTOSAVE" name="BAR" value="SUBMIT" />
                              </form>
                              </body>
                              </html>

                              ---
                              Archimedes Trajano http://www.trajano.net/

                              *** Sent via Developersdex http://www.developersdex.com ***

                              Comment

                              Working...