<html>
<title>午饭吃什么?</title>
<head><meta http-equiv=Content-Type content="text/html; charset=utf-8">
</head>
<body>
<script type="text/javascript">
var alldata = "正宗的兰州牛肉面,可口的炒菜米饭,非常香的馄饨,西安肉夹馍和粥,过桥米线或者米粉,黄焖鸡米饭,找个面馆吃面,喝粥,泡面,去超市吃盒饭,去吃肯德基、麦当劳,不吃了"
var alldataarr = alldata.split(",");
var num = alldataarr.length-1 ;
var timer
function change()
{
document.getElementById("oknum").innerHTML = alldataarr[GetRnd(0,num)];
}
function start(){
clearInterval(timer);
timer = setInterval('change()',10);
}
function ok(){
clearInterval(timer);
document.getElementById("showresult").value=document.getElementById("oknum").innerText;
}
function GetRnd(min,max){
return parseInt(Math.random()*(max-min+1));
}
</script>
<center>
<div id="oknum" name="oknum" >请单击开始</div>
<button onclick="start()" accesskey="s">开始选择吧</button>
<button onclick="ok()" accesskey="o">点击进行决定</button>
您的选择是:
<input type="text" id="showresult" value="">
</center>
</body>
</html>
阅读全文
收起全文