如何创造动态增长的价值?

发布于 2024-09-28 18:29:19 字数 185 浏览 11 评论 0原文

我想创建并显示一个每秒增加固定量的值。

我的 PHP 文件中有以下变量:

$AccountValue=220000; $IncreasePerSecond=15;

因此,例如,当页面加载时,一秒后该值将是 220000,另一秒后该值将是 220015 220030 ....等等,

提前致谢

I want to create and display a value which is increasing by a fixed amount per second.

I have the following variables in my PHP file:

$AccountValue=220000;
$IncreasePerSecond=15;

So for example when the page loads the value would be 220000 after one second the value would be 220015 after another second 220030 ....etc

thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绝情姑娘 2024-10-05 18:29:19

我认为最好用 javascript 编写,即客户端(正如 Wernight 已经在他的 答案

在服务器端,您可以记录该点秒数开始增加。
然后,当再次请求该页面时,您可以在服务器端计算起始点和当前时间之间的秒数。

I think it's best to write this in javascript, i.e. client-side( as Wernight already shows in his answer.

On the server-side you can record the point at which the seconds start to increase.
Then when the page gets requested again you can calculate on the server-side the amount of seconds that are between the starting point and the current time.

醉酒的小男人 2024-10-05 18:29:19

这不是完整的答案,但它应该为您提供基础:

var count = 0;
setIncrement("doSomething()", 1000);
function doSomething()
{
  document.getElementById("my_div").innerHTML = ++count;
}

请参阅 http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/

It's not the full answer but it should give you the basis:

var count = 0;
setIncrement("doSomething()", 1000);
function doSomething()
{
  document.getElementById("my_div").innerHTML = ++count;
}

See http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文