You are here: irt.org | FAQ | JavaScript | Object | Q1564 [ previous next ]
Try:
<html> <head> <script language="JavaScript"><!-- var globalVariable; function makeArray(size) { // create array: globalVariable = new Array(parseInt(size)); // populate array: for (var i=0; i<globalVariable.length; i++) { globalVariable[i] = 'Hello world'; } // display array contents: var o = ''; for (var i=0; i<globalVariable.length; i++) { o += globalVariable[i] + '\n'; } alert(o); } //--></script> </head> <body> <form> <input type="text" onChange="makeArray(this.value)"> </form> </body> </html>