Solved

Automatically click button after certain number of seconds / pause

Posted on 2011-02-28
4
291 Views
Last Modified: 2012-06-27
Hi Experts

I have the following HTML button that I would like to be clicked automatically after 5 seconds. How can I do this?

Here is the code for the button:

<input type="submit" name="proceed" value="Click here to continue to Step 3 - Payment Details" />

And here is the code for the <form> tag for the form in which this button is located:

<form enctype="application/x-www-form-urlencoded" name="cartCheckout" method="POST" action="<%=checkOutURL%>" autocomplete="off">



Thanks

Wes


0
Comment
Question by:wesmanbigmig13
[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
4 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 35003009
You should be able to directly use :
window.onload = function() { setTimeout('document.forms["cartCheckout"].submit()', 5000); }

Open in new window

0
 

Author Comment

by:wesmanbigmig13
ID: 35003151
Thanks - but do I add this into the <head> section, the <body> tag, or in the main code area for the page?

0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 35003163
Test page :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
	window.onload = function() {
		setTimeout('document.forms["cartCheckout"].submit()', 5000);
	}
</script>
</head>
<body>
<form enctype="application/x-www-form-urlencoded" name="cartCheckout" method="POST" action="http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_26854084.html" autocomplete="off">
	<input type="submit" name="proceed" value="Click here to continue to Step 3 - Payment Details" />
</form>
</body>
</html>

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 35003166
>Thanks - but do I add this into the <head> section, the <body> tag, or in the main code area for the page?


yes, it run at page load, when the page is successfully loaded, the code start counting the five second and submit your form :
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn how to count occurrences of each item in an array.
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)

752 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