Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

body onload="SubmitForm()" 1

Status
Not open for further replies.

OldWilly

Programmer
Mar 1, 2002
66
I'm trying to submit a form w/o using a submit button.
But I'm getting "object expected". Code following.

<body onload=&quot;SubmitForm()&quot;>
<form method=&quot;POST&quot;
action=&quot;<!-- The following fields are required: -->
<input type=&quot;hidden&quot; name=&quot;LOGIN&quot; value=&quot;tmhracing2&quot;>
<input type=&quot;hidden&quot; name=&quot;PARTNER&quot; value=&quot;verisign&quot;>
<input type=&quot;hidden&quot; name=&quot;AMOUNT&quot; value=&quot;10.95&quot;>
<input type=&quot;hidden&quot; name=&quot;TYPE&quot; value=&quot;A&quot;>
<input type=&quot;hidden&quot; name=&quot;DESCRIPTION&quot; value=&quot;Your TMH Racing Order&quot;>
<input type=&quot;hidden&quot; name=&quot;NAME&quot; value=&quot;William Pontius&quot;>
<input type=&quot;hidden&quot; name=&quot;ADDRESS&quot; value=&quot;124 E. Pine St.&quot;>
<input type=&quot;hidden&quot; name=&quot;CITY&quot; value=&quot;Johnsonville&quot;>
<input type=&quot;hidden&quot; name=&quot;STATE&quot; value=&quot;SC&quot;>
<input type=&quot;hidden&quot; name=&quot;ZIP&quot; value=&quot;29555&quot;>
<input type=&quot;hidden&quot; name=&quot;COUNTRY&quot; value=&quot;USA&quot;>
<input type=&quot;hidden&quot; name=&quot;EMAIL&quot; value=&quot;bill@e-databasedesign.com&quot;>
<input type=&quot;hidden&quot; name=&quot;PHONE&quot; value=&quot;8433863631&quot;>
<input type=&quot;hidden&quot; name=&quot;NAMETOSHIP&quot; value=&quot;William Pontius&quot;>
<input type=&quot;hidden&quot; name=&quot;ADDRESSTOSHIP&quot; value=&quot;124 E. Pine St.&quot;>
<input type=&quot;hidden&quot; name=&quot;CITYTOSHIP&quot; value=&quot;Johnsonville&quot;>
<input type=&quot;hidden&quot; name=&quot;STATETOSHIP&quot; value=&quot;SC&quot;>
<input type=&quot;hidden&quot; name=&quot;ZIPTOSHIP&quot; value=&quot;29555&quot;>
<input type=&quot;hidden&quot; name=&quot;COUNTRYTOSHIP&quot; value=&quot;USA&quot;>
<input type=&quot;Submit&quot; value=&quot;Submit&quot;>
</form></body>

Any ideas would be appreciated.
 
can we see your SubmitForm() function?????
 
oh jeez! no wonder it didn't work! I don't have the function. Do you have a quick and dirty one I can use?
(I'm a CF programmer and am pretty weak with JavaScript).
 
you have to define your function inside of the <head> tags. Copy this code and paste it between the <head> and </head>.

<script language=&quot;JavaScript&quot;>
<!--
function SubmitForm(){
window.location=&quot;}
//-->
</script>

this is as you said a quick and dirty of doing it though!!!!
 
sorry, I thought I was making a typo mistake but it is how its displayed on the site. for the window.location value, there shouldn't be two semicolons at the end. The first one should be a quote (&quot;) to close your string value.

eg. window.location=&quot;cgi&quot;;
 
I also got another answer that does not require a function ...

<body onload=&quot;document.test.submit();&quot;> where &quot;test&quot; is the name of the form

thx for your help
 
Unless you put a timer on your function, the form won't submit because you're trying to submit the form before the form exists.

The <body onload=&quot;SubmitForm()&quot;> tag and function call will try to submit the form before the page is rendered and will continue to give you errors.



There's always a better way. The fun is trying to find it!
 
Unless I'm very much mistaken, tviman, onload triggers once the page is loaded.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top