javaScript自动选号

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script type="text/javascript">
 function randomNum(){
  var num ;
  for(var i=0;i<6;i++){
   num = Math.round(Math.random()*31);
   if(num < 10){
    num = "0"+num;
   }
   document.getElementById("t"+i).value = num;
  }
 }
</script>
</head>
 
<body>
<form name="form1" method="post" action="">
  <input type="text" name="t0" size="5" id="t0">
  <input type="text" name="t1" size="5"  id="t1">
  <input type="text" name="t2" size="5" id="t2">
  <input type="text" name="t3" size="5" id="t3">
  <input type="text" name="t4" size="5" id="t4">
  <input type="text" name="t5" size="5" id="t5">
  <input type="button" name="Submit" value="选号" onClick="randomNum()">
</form>
</body>
</html>

你可能感兴趣的:(JavaScript,js,随机数,职场,休闲)