js数字随机产生并相加

 1   <input type="text" value="" name="plus1" id="plus1" size=5/><label> + </lable>
 2   <input type="text" value="" name="plus2" id="plus2" size=5/><label> = </lable>
 3   <input type="text" value="" name="And" id="and" size=5/>
 4   <input type="button" value="提交" onclick="show()"/>
 5 <script>
 6    //var t = 1000; //在这里设置刷新时间,单位是毫秒,比如1秒钟就是1000
 7    var min = 0; //生成的最小的数字,比如200
 8    var max = 100; //生成的最大的数字,比如500
 9    var ctl_id = "show"; //要在哪个控件中显示,比如例子中的"show"
10    onload = function() {
11       Refresh();
12       //setInterval("Refresh();", t);
13     }
14 
15     function Refresh() {
16 
17             document.getElementById('plus1').value = parseInt(Math.random() * (max - min)+ min);
18              document.getElementById('plus2').value = parseInt(Math.random() * (max - min)+ min); 
19     }
20     function show(){
21             
22             var plus1=document.getElementById('plus1').value;
23             var plus2=document.getElementById('plus2').value;
24             var and=document.getElementById('and').value;
25             var plus3=eval(plus2+"+"+plus1)
26             if(and==plus3)  {
27                 window.location='linpin.com';
28             }
29             else{
30                 alert("验证码错误!");
31             }
32 }
33 
34 </script>
if you don't try,you will never know!
原文地址:https://www.cnblogs.com/leeten/p/3447753.html