Solved

Automatically click button after certain number of seconds / pause

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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 learn how to dynamically set the form action using jQuery.

831 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