本帖最后由 phpcainiao 于 2010-10-28 18:47:03 编辑

解决方案 »

  1.   

    其实不用这么麻烦。你直接去select的值作为你要的最大数字呗
      

  2.   

    <html>
    <head>    <script type="text/javascript" language="JavaScript">    
      var   timer   
      function   change(){   
        document.getElementById("oknum").value = Math.floor(Math.random()*(parseInt(document.getElementById("a1").value))) + 1;
      }      
      function   start(){   
          clearInterval(timer);   
          timer = setInterval('change()',1); //随机数据变换速度,越小变换的越快   
      }      
      function   ok(){   
        clearInterval(timer);   
      }   
        </script></head>
    <body>
        <select name="a1" id="a1">
            <option>请选择随机数最大值</option>
            <option value="100">随机数最大值一</option>
            <option value="200">随机数最大值二</option>
            <option value="300">随机数最大值三</option>
            <option value="400">随机数最大值四</option>
        </select>
        <input type="text" id="oknum" name="oknum" value="">
        <button onclick="start()" accesskey="s">
            开始抽奖(<u>S</u>)</button>
        <button onclick="ok()" accesskey="o">
            停止(<u>O</u>)</button>
    </body>
    </html>