zoukankan      html  css  js  c++  java
  • 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!
  • 相关阅读:
    第3章 Python的数据结构、函数和文件
    字符与编码
    第2章 IPython和Jupyter
    第1章 准备工作
    (转)详解Python的装饰器
    (转)Python中的split()函数
    5.5 用户定义的可调用类型
    2.6 序列的增量赋值
    Zookeeper简析
    Dubbo-服务引入源码分析
  • 原文地址:https://www.cnblogs.com/leeten/p/3447753.html
Copyright © 2011-2022 走看看