随机数生成器,无需刷新 [英] random number generator without doing refresh

查看:127
本文介绍了随机数生成器,无需刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好 我想创建一个网页,该网页可以不进行刷新就可以连续向数据库发送随机值.

Hello I want to create a web page which can continually sending random value to data base without doing refresh .

例如

<html>
  <HEAD>
    <TITLE>HTML Title</TITLE>
  </HEAD>
  <BODY>

    <H3 ALIGN="CENTER">
      Ramdom number from 0 to 10 : 
      <FONT COLOR="RED">
        <%= (int) (Math.random() * 10) %>
      </FONT>
    </H3>
    <H4 ALIGN="CENTER">Refresh the page to see if the number changes...</H4>
  </BODY>
</HTML>

我应该使用applet还是可以轻易采用的东西朝哪个方向发展.谢谢

in which direction i should go either of using applets or something which can easily be adopted . Thanks

推荐答案

您可以使用JavaScript来做到这一点.这非常简单.

You can use JavaScript to do this. It's extremely simple.

window.onload = function ()
{
    var output = document.getElementById('foo');

    setInterval(function ()
    {
        output.innerHTML = Math.floor(Math.random() * 10);
    }, 1000);
};

演示: http://jsfiddle.net/mattball/c9t3T/

基于示例中的HTML,您可能应该花一些时间并开始学习 CSS 以及.

Based on the HTML in your example, you should probably take some time and start learning CSS as well.

这篇关于随机数生成器,无需刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆