Re: Shift with arrays

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

 Date:  Sat, 28 Jun 2003 18:32:10 +1000
 To:  <hwg-techniques(at)hwg.org>
 References:  apto
  todo: View Thread, Original
OK. References.

----- Original Message -----
From: "John" <johnmoz(at)ozemail.com.au>
To: <hwg-techniques(at)hwg.org>
Sent: Saturday, June 28, 2003 12:58 PM
Subject: Shift with arrays


> 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