hwg-techniques archives | Jun 2003 | new search | results | previous | next |
Shift with arraysby "John" <johnmoz(at)ozemail.com.au> |
|
Why does the following not run twice. That is, why if you click the button the second time doesn't the docment have the same five lines written again - every time you click the button? <.html> <.head> <.script type="text/javascript"> aGoYouGoodThing = new Array(10,20,30,40,50); function doMe(arrayIn){ aHere = new Array(); aHere = arrayIn; while (aHere[0]){ alert(aHere[0]); aHere.shift(); document.all("divOne").insertAdjacentHTML("BeforeEnd", "<div>This" + aHere[0] + "</div>"); } } </script> </head> <.body> <.form name="myForm"> <.input type="button" onclick="doMe(aGoYouGoodThing)" value="Bands"> <.div id="divOne"> </div> </form> </body> </html>
HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA