Re: For Loop Help
- From: "Craig L" <w1zard10@xxxxxxxxxxxxxxx>
- Date: Tue, 6 Sep 2005 11:12:49 -0500
Thanks for the quick response. At this point I'm just trying to declare the
variables image1, image2, image3, etc. for use later in the script, rather
than typing var image1, image2, . . ., image 20, image21, etc. The "image" +
i code is getting close, I think. Hope this helps to clarify.
Craig
"McKirahan" <News@xxxxxxxxxxxxx> wrote in message
news:Q-2dnfZ5VoCjI4DeRVn-pA@xxxxxxxxxxxxxx
> "Craig L" <w1zard10@xxxxxxxxxxxxxxx> wrote in message
> news:48GdnS5u1MdtJIDeRVn-qg@xxxxxxxxxxxxxx
>> A simple question - How do I convert
>>
>> var image1, image2, image3, image4
>>
>> To a for loop that changes the variable name so I don't have to list
>> them,
>> Like
>>
>> for (var i = 1; i <= 4; i++) {
>> var image??
>> }
>>
>> Thanks for the help.
>
> Not quite sure what you're asking for....
>
> <html>
> <head>
> <title>varImage.htm</title>
> <script type="text/javascript">
>
> var image1 = "a.gif";
> var image2 = "b.gif";
> var image3 = "c.gif";
> var image4 = "d.gif";
>
> // To a for loop that changes the variable name so I don't have to list
> them,
>
> for (var i=1; i<5; i++) {
> alert(eval("image" + i));
> }
>
> // eval() is evil ...
>
> </script>
> </head>
> <body>
> </body>
> </html>
>
>
> http://blogs.msdn.com/ericlippert/archive/2003/11/01/53329.aspx
>
>
.
- Follow-Ups:
- Re: For Loop Help
- From: Andrew Scott
- Re: For Loop Help
- References:
- For Loop Help
- From: Craig L
- Re: For Loop Help
- From: McKirahan
- For Loop Help
- Prev by Date: Re: For Loop Help
- Next by Date: Re: show/hide thingy
- Previous by thread: Re: For Loop Help
- Next by thread: Re: For Loop Help
- Index(es):
Relevant Pages
|