submitting a form through another frame

T

threeflush

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

Erwin Moller

threeflush said:
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
 
T

threeflush

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!!!!!**
 
T

threeflush

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

eric

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

threeflush

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!).
 
T

threeflush

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

threeflush

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

threeflush

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

Archimedes Trajano

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").click();
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>
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top