Click to See Complete Forum and Search --> : Issue with submit()


WolfShade
10-16-2003, 04:22 PM
I'm trying to get a form full of TYPE="HIDDEN" to automatically submit after the page loads (it's for an internal application that generates a PDF based upon the form fields.)

The problem is that the function I'm using has been used in other pages with a 50/50 chance of it working. In this case, it's one of those that isn't working and I can't figure out why.

Here is the code I'm using, followed by the error message that I'm getting:

function getPDF() {
df = document.FormOne;
df.action = "generatePDF.asp";
df.method = "post";
df.submit();
}
setTimeout("getPDF()",3000);

Error: Object doesn't support this property or method
(Specifically points to "df.submit();")

Any ideas as to why this sometimes works and sometimes won't?

gil davis
10-16-2003, 05:31 PM
Are you sure the form is loaded when the timeout fires? Or are you guessing that 3 seconds is long enough? You really ought to do it qualified by the onLoad event.

WolfShade
10-16-2003, 05:40 PM
Originally posted by gil davis
Are you sure the form is loaded when the timeout fires? Or are you guessing that 3 seconds is long enough? You really ought to do it qualified by the onLoad event.

I'm sure three seconds is enough. Regardless of what triggers the event, the same error message comes back (does not support property or method.) I did try it, a few times, using onLoad=, but the same error message is coming up.

I've seen this work flawlessly on certain pages, and not at all on others; I'm just flabbergasted coz I can't understand why it sometimes will and sometimes won't (always in PC IE 6.0 with all patches, Win2kPro).

PS. The reason why I'm sure that three seconds is long enough is because the fields are being filled by a database query - if the fields weren't filled out, I'd get a different error. Plus, I set it to 30 seconds, same error message.

WolfShade
10-16-2003, 06:37 PM
Nevermind.. it's fixed. I used to know that having an object named "submit" would override a js submit; I don't know why I forgot that. All I did was rename the submit button (there in case the user doesn't have js enabled) to submitfrm and it worked.

sigh..