What script do I need to say something like this..."11 new females have joined in the past hour" with the number constantly increasing by random increments 11 -> 14 -> 15 -> 19 -> 26 -> 31
http://php.about.com/od/phpfunctions...random_num.htm
Any idea on the javascript code?
Would it look like this <script>whatever the code is</script> new females have joined in the past hour?
I think http://stmforum.com/forum/showthread...r-Your-Landers will do what you need!
Here ya go
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
// This is in milliseconds
var delay_seconds = 1000
var female_count = 11
setInterval(function() {
// This is maximum number to increment count by
var increment_max = 5
// Get random number between 1 and increment_max
var rand_num = Math.floor(Math.random() * increment_max) + 1
// Add random number to current count
female_count += rand_num
document.getElementById("random_number").innerHTML = female_count
}, delay_seconds)
</script>
</head>
<body>
<span id="random_number">11</span> new females have joined in the past hour
</body>
</html>
Thanks man
why not this?
@JasperP, how could I decrease the count instead of increase? Also, how can I make sure the count doesn't go below 5? I want to do 100 spots left and have it go down from there.
why javascript not php, i prefer everything php
PHP is only server side ... whatever content is returned to the client browser is what is shown. Javascript can modify the DOM on the client side and update with a timer what is shown to the user.