Solved

Automatically click button after certain number of seconds / pause

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Read about why website design really matters in today's demanding market.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now