Shift with arrays

by "John" <johnmoz(at)ozemail.com.au>

 Date:  Sat, 28 Jun 2003 12:58:43 +1000
 To:  <hwg-techniques(at)hwg.org>
  todo: View Thread, Original
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