自动选择器

<textarea name="name" id="name" style="width:800;height:200">张学友,郭富城,刘德华,黎明,游鸿明,周润发,周星驰,王杰,动力火车,羽泉,邰正宵,邓丽君,赵薇</textarea><br>
<input type="submit" name="submit" value="提交" style="width:100px" />
<br>
<input type="button" name="button" value="开始" style="width:100px" onclick="myclick(1)" />
<input type="button" name="button2" value="结束" style="width:100px" onclick="myclick(0)" />
<div id="result"></div>


<script type="text/javascript" src="jquery.js"></script>
<script language="javascript">

var str
var temp;
function GetRandomNum(){
 str = $("#name").val();
 var arr=str.split(",");
 
 var Max = arr.length;
 var Min = 0;
 var Rand = Math.random();
 
 $("#result").html(arr[Math.round(Rand * Max)]);
}
function myclick(click){
 if(click == 1){  
  temp=setInterval(GetRandomNum,1);  
 }else if(click == 0){
  clearInterval(temp);
 }
}
</script>

你可能感兴趣的:(自动选择器)