|
四位随机数:- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
- <head>
- <title>四位随机数</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="description" content="" />
- <meta name="keywords" content="" />
- <script type="text/javascript">
- var charactors="0123456789";
- var value = '',i;
- for(j=1;j<=4;j++){
- i = parseInt(10*Math.random());
- value = value + charactors.charAt(i);
- }
- alert(value);
- </script>
- <style type="text/css">
- </style>
- </head>
- <body>
-
- </body>
- </html>
复制代码 修改属性:- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
- <head>
- <title>修改文本框的value</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="description" content="" />
- <meta name="keywords" content="" />
- <script type="text/javascript">
- function oncl(){
- var sjs = document.getElementsByName('sjs')[0];
- sjs.value = '213451';
- }
- </script>
- <style type="text/css">
- </style>
- </head>
- <body>
- <input type="text" name="sjs" />
- <input type="submit" value="提示文字" onclick="oncl();"/>
- </body>
- </html>
复制代码 判断文本框是否相等:- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
- <head>
- <title>新建网页</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="description" content="" />
- <meta name="keywords" content="" />
- <script type="text/javascript">
- function oncl(){
- var sjss = document.getElementsByName('sjs')[0];
- var gdss = document.getElementsByName('gds')[0];
- if(sjss.value != gdss.value){
- alert('不相等');
- }else{
- alert('相等了');
- }
- }
- </script>
- </head>
- <body>
- <input type="text" name="sjs" />
- <input type="text" name="gds" />
- <input type="submit" value="提示文字" onclick="oncl();"/>
- </body>
- </html>
复制代码 三个合起来怎么搞都不行,要求是一个文本框内容是从js的四位随机数,而另一个文本框是自己填的四位数字,两个文本框判断是否相等,如果不相等随机数继续随机再判断是否相等. |
|