Solved

Automatically click button after certain number of seconds / pause

Posted on 2011-02-28
4
292 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

Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

635 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