Mega Code Archive

 
Categories / JavaScript DHTML / Form Control
 

Feed value from array to text box

<html> <head> <title>Simple Array Demo</title> <script> var counter = 0; function upDate(){   counter++;   if (counter > 3){     counter = 0;   }   var description = new Array(3)   description[0] = "A";   description[1] = "B";   description[2] = "C";   description[3] = "D";   document.myForm.txtDescription.value = description[counter]; } </script> </head> <body onLoad = "initialize()"> <center> <form name = "myForm"> <input type = "text" value = "A" name = "txtDescription"> <input type = "button" value = "next" onClick = "upDate()"> </form> </center> </body> </html>