Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Automatically hitting a submit button

Posted on 2001-08-10
12
Medium Priority
?
385 Views
Last Modified: 2010-08-05
This may sound perverse, but:

I have a form with a submit button on it. Every element on the form is input type = hidden. As soon as the page is loaded I want JavaScript to automatically hit the button so the page will submit the details to the web server and deliver the next page.

(It?s a long and boring story why I?m not using a link like meta http-equiv="refresh".)

Thank you for your help and time,

Stoke
0
Comment
Question by:Stoke
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +1
12 Comments
 
LVL 3

Expert Comment

by:CyberSoft
ID: 6371948
Hi Stoke,

In your body tag place the following (assuming your form is called "frmAutoSubmit"):

onload="document.frmAutoSubmit.submit()"

That should automatically submit the form once the page has completed loading in the browser.

Regards,
CyberSoft
0
 
LVL 9

Expert Comment

by:nimaig
ID: 6371965
use
<body onLoad="document.forms[0].submit()">
0
 

Author Comment

by:Stoke
ID: 6371998
Dear Cybersoft and nimaiq,

I know you've right, but I'm getting a script error, "Object doesn't support this property or method" I must be doing something really silly. Here is the body and the form tag:

<body onload="document.frmAutoSubmit.submit()">

<FORM action="www.example.com" NAME="frmAutoSubmit" method=post>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:nimaig
ID: 6372039
Try this:

<html>
<head>
</head>
<body onload="document.frmAutoSubmit.submit()">
<FORM action="http://otnxchange.experts-exchange.com/jsp/qShow.jsp?qid=20166375" NAME="frmAutoSubmit" method=post> </FORM>
</body>
</html>
0
 
LVL 3

Accepted Solution

by:
CyberSoft earned 200 total points
ID: 6372066
Hey Stoke,

What browser, version and OS are you using? I've just tested the code in IE5.5, NS4.78 and NS6 on Windows 2000 and it works fine - Netscape 4.78 must have at LEAST one form field between the form tags for it to work though.

Regards,
CyberSoft
0
 

Author Comment

by:Stoke
ID: 6372194
I'm using Windows ME and IE5.5

I've cut the form down to the minimum - here is the full lot:

<html>
<head>
</head>
<body onload="document.frmAutoSubmit.submit()">
<FORM action="http://www.experts-exchange.com" NAME="frmAutoSubmit" method=post>
<INPUT type="hidden" name="Test" value="test">
<INPUT name="submit" type=submit value="Submit">
</FORM>
</BODY></HTML>

I think I must be doing something really stupid!

Stoke
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6372216
You are.
Do not call the button submit

Michel
0
 
LVL 9

Expert Comment

by:nimaig
ID: 6372219
Remove <INPUT name="submit" type=submit value="Submit">
or use different name for the submit button
<INPUT name="submit1" type=submit value="Submit">

This is because the submit button name conflicts with the submit() method of the form.

<html>
<head>
</head>
<body onload="document.frmAutoSubmit.submit()">
<FORM action="http://otnxchange.experts-exchange.com" NAME="frmAutoSubmit" method=post>
<INPUT type="hidden" name="Test" value="test">
<INPUT name="submit1" type=submit value="Submit">
</FORM>
</BODY>
</HTML>
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6372222
change
<INPUT name="submit" type=submit value="Submit">
to
<INPUT name="Submit" type=submit value="Submit">

and document.frmAutoSubmit.submit
is no longer the submit button
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6372224
Beat you by a minute ;-)
0
 

Author Comment

by:Stoke
ID: 6372287
Brilliant work fellas!

Full marks all round. I've awarded this to Cybersoft because he/she was the first one with the answer, but I really want to thank everyone. It's helped me no end.

Thanks very much,

Stoke
0
 
LVL 3

Expert Comment

by:CyberSoft
ID: 6372355
Sorry guys went out for a while. Glad you got it working in the end Stoke. Thanks for accepting my solution as the answer.

Regards,
CyberSoft
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question