Return to Snippet

Revision: 63371
at May 2, 2013 01:34 by scorpayllc


Initial Code
<html>
<head>
<title>Landing Page</title>
<style>
.timer {
	color:red;
	border:none;
	font-family:verdana;
	font-size:16pt;
	font-weight:bold;
	border-right-color:#FFFFFF
}
</style>
</head>

<script>
// Random Countdown Timer Script, by http://ctrtard.com
var timer;
function startCount()
{
	timer = setInterval(count,200); // 200 = 200ms delay between counter changes. Lower num = faster, Bigger = slower.
}
function count()
{
	var rand_no = Math.ceil(9*Math.random()); // 9 = random decrement amount. Counter will decrease anywhere from 1 - 9.
	var el = document.getElementById('counter');
	var currentNumber =	parseFloat(el.innerHTML);
	var newNumber = currentNumber - rand_no;
	if (newNumber > 0) {
		el.innerHTML = newNumber;
	} else {
		el.innerHTML = "Sold Out";  // This message is displayed when the counter reaches zero.
	}
}
</script>

<body onLoad="startCount();">

<span class="timer"><span id="counter">431</span></span>

</body>

</html>

Initial URL

                                

Initial Description

                                

Initial Title
"Sold Out" Javascript Random Countdown Script

Initial Tags

                                

Initial Language
JavaScript