[Javascript] dynamic variables names

Geoff Corriere geoff at cpe1.com
Tue Jun 24 10:58:02 CDT 2003


I create a variable to hold the name of the object first. Then use it 
in the array.

foo(i){
var next_element = "nt_o" + i;
document.images[next_element].src = '../_img/1_nota_0'+i+'_on.gif';
}


On Tuesday, June 24, 2003, at 10:50  AM, Marcelo Simon wrote:

> Hi list,
>  
> It's me again, and I need some help again please.
>  
> how can I use dynamic variables name in JS ?
>  
> I mean, how do I evaluate the 2 parts so they work ?
>  
> if ( i <= number ){
>    ['nt_o'+i].src = '../_img/1_nota_0'+i+'_on.gif';
> }
>  
> thanks in advance
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 841 bytes
Desc: not available
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20030624/6c9cb8d4/attachment.bin>


More information about the Javascript mailing list