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

相關文章
相關標籤/搜索