<html>
<head>
<title>生成随机数字</title>
<script type="text/javascript">
function testradom(form)
{
  var strRadom=Math.floor(Math.radom()*1000) +1;
  alert(strRadom);
}
</script>
</head>
<body>
<div style="MARGIN:15px auto; background-color: #9ACDCD;">
<H2>生成1-1000之间的随机数字</H2>
<form id="forml" name="forml" onsubmit="return false">
<input type="submit" name="submit3" value="生成随机数"
onclick="testradom(this.form)"/>
</form>
</div>
</body>
</html>

解决方案 »

  1.   


    <html>
    <head>
    <title>生成随机数字 </title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <script type="text/javascript">
    function testradom(form)
    {
    alert('aa');
      var strRadom = Math.floor(Math.random()*1000) +1;
      alert(strRadom);
    }
    </script>
    </head>
    <body>
    <div style="MARGIN:15px auto; background-color: #9ACDCD;">
    <H2>生成1-1000之间的随机数字 </H2>
    <form id="forml" name="forml">
    <input type="button" value="生成随机数" onClick="testradom(document.forml)"/>
    </form>
    </div>
    </body>
    </html>
      

  2.   

    var strRadom=Math.floor(Math.radom()*1000) +1; 这句错了~·random
      

  3.   

    var strRadom=Math.floor(Math.radom()*1000) +1; 
    符号不对你的分号