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

submitting a form through another frame

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

Jul 23 '05 #1
Share this Question
Share on Google+
14 Replies


P: n/a
threeflush wrote:
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.formname.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?


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
Jul 23 '05 #2

P: n/a
threeflush wrote:
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.formname.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?

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="document.forms[0].submit()">

Is that what you're asking?
Jul 23 '05 #3

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

Jul 23 '05 #4

P: n/a
threeflush wrote:
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!!!!!**

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?
Jul 23 '05 #5

P: n/a
What do you mean by "validating"? I'll post an abridged version
shortly... Thanks.

Jul 23 '05 #6

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

Jul 23 '05 #7

P: n/a
threeflush wrote:
What do you mean by "validating"? I'll post an abridged version
shortly... Thanks.

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/
Jul 23 '05 #8

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

Jul 23 '05 #9

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

Jul 23 '05 #10

P: n/a
http://www.plsgoogleit.com

"threeflush" <da********@gmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
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.

Jul 23 '05 #11

P: n/a
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!
Jul 23 '05 #12

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

Jul 23 '05 #13

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

Jul 23 '05 #14

P: n/a
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("formsubmit.html");
submitter.document.getElementById("FOOID").value =
document.getElementById("FOOID").value;
submitter.document.getElementById("AUTOSAVE").clic k();
submitter.close();
}
</script>
<body onunload="doSubmit()">
<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 ***
Aug 29 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.