View Full Version : A calculation script of %?

12-02-2009, 03:20 AM
I was woundering if their is a such html code that I input a value (say 1000) and ti automatically adds 5% to it every say 30 minutes? Is their a such script?

Like if someone said the number 1000 on the website, and locked in the value. They need to get 10% every 30 minutes. Is taht possible?

12-02-2009, 05:30 PM
here's a jQuery solution:

Since you didn't specify, this example will add 10% of the entered value exponentially to the total value. Ie, every 3 seconds it will take 10% of the total and add it to the toal. Then 3 seconds later it will find 10% of the new total and ad it to it and so on.

Should be pretty straight forward as I added comments to the JS by the areas that need to be changes to suit your needs.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {
// begin

// below is the amount you want to add in percentages (decimal)
var basepercent = ".10";
//below is the speed in which you want to add in miliseconds
var speed = "3000"; //that's 3 seconds. 30 minutes would be 1800000

$("#start").click(function () {
var starttime = $("#time").val();
var percentage = basepercent * $("span.num:eq(1)").text()

var percentage = basepercent * $("span.num:eq(1)").text()
var total = 0;
$("span.num").each(function() {
total += parseFloat($(this).text()) || 0;
total = Math.round(total);
$("#counter span").text(total);
}, speed);


// end

<form action="" method="post">
<input type="text" name="time" id="time">
<a href="#" id="start">Start</a>
<div>Your multiplier: <span class="num"></span></div>
<div id="counter">Your counter: <span class="num"></span></div>

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum