Form to automatically execute after the page is already loaded not at onload

I need a way other than "window.onload " to execute “myform.Submit1”.

As I have it now the Submit button executes “myform” correctly if you do it manually.

I want “myform” to automatically execute after the page is already loaded not at onload.

<body>
...
	<script type="text/javascript">
        window.onload = function () {
        	document.myform.Submit1.click();
        	self.location="http://mysite.com/webpage.php";
        }
    </script>
</body>

I think you need to clarify what you mean. When do you want the form to be submitted?
Immediately after the page has loaded without any user interaction?
When a user clicks submit?

I want the form to be submitted directly after the page is loaded.
I do not want any interaction with the page at all just a blip and back to the main page.
As of now the page shows a lone Submit Button and “windows.onload” does nothing.
If I select the Submit Button it executes the form perfectly.
I want JavaScript to do it after the page is loaded.

Changing .click() to .submit() should do the job. Are you sure JavaScript is the best place to do this for what you want? A user may have JavaScript disabled.

What is the purpose of the form (or the page) if you’re immediately submitting an empty form? Are you looking for a way to do a redirect? If so, there are better ways to do this that don’t rely on forms and JavaScript.

I am looking to redirect after the submit button is pressed.

Automatically Submit button pressed then redirect.

Nothing on the page is viewable all hidden boxes only thing viewable is the submit button.

You’re aware people can see the hidden stuff though right? So if you put anything sensitive there, they can see it. (right click, view source). And if JavaScript is disabled, they won’t be redirected automatically.

I understand what you’re trying to do, but I’m interested in why you want to do it. If you’re just redirecting the page as soon as it’s loaded, why load the page at all? Are you showing a message to the user like “Thanks for logging in. You’ll be redirected to page x now” or something?

I am using a javascript button to submit the main page form.

I do php calculations in this current form and I want to automatically submit this form back to the main page.

The whole thing is I want a button action with a form in my main page acting as if you never left the main page plus sending the data back.

Can’t you just do those calculations when the user first requests the main page (and bypass the form altogether)? What information are you trying to get in order to do calculations?

OK, well have you thought about submitting the first form via AJAX? The target script could do the processing and return some data, and the user would never have to leave the first page.