<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
var functions = [change0,change1,change2,change3];
function getRandom(min, max)
{
var randomNum = Math.random() * (max-min);
return(Math.round(randomNum) + min);
}
function change0() {
document.getElementById("text").innerHTML="Change0";
}
function change1() {
document.getElementById("text").innerHTML="Change1";
}
function change2() {
document.getElementById("text").innerHTML="Change2";
}
function change3() {
document.getElementById("text").innerHTML="Change3";
}
function choose() {
var ry = getRandom(0, 3)
functions[ry]();
}
</script>
</head>
<body>
<div id="text1"><div id="text"></div></div>
<input type="button" onclick="choose()" value="click me" />
</body>
</html>
|