/*
JavaScript Programming for the Absolute Beginner
by Andy Harris
Publisher: Muska & Lipman/Premier-Trade
Language: English
ISBN: 0761534105
*/
<html>
<head>
<title>Simple Array Demo</title>
<script>
var description = new Array(3)
var counter = 0;
function initialize(){
// sets up the array with some startin values
// Andy Harris
description[0] = "blank";
description[1] = "triangle";
description[2] = "circle";
description[3] = "square";
} // end initialize
function upDate(){
//increments the counter and shows the next description
counter++;
if (counter > 3){
counter = 0;
} // end if
document.myForm.txtDescription.value = description[counter];
} // end upDate
</script>
</head>
<body onLoad = "initialize()">
<center>
<h1>Simple Array Demo<hr></h1>
<form name = "myForm">
<input type = "text"
value = "blank"
name = "txtDescription">
<br>
<input type = "button"
value = "next"
onClick = "upDate()">
</form>
</center>
<hr>
</body>
</html>
|