[Javascript] dynamic variables names
Marcelo Simon
grillo at lazzuri.com.br
Tue Jun 24 15:04:26 CDT 2003
Thanks all,
I've solved it with all of your help. First did it with eval(), and now
changed it to the images collection
here's the working code
function nota(numero){
for ( var i=1; i < 6; i++){
if ( i <= numero ){
document.images["nt_0"+i].src = '../_img/1_nota_0'+i+'_on.gif';
} else {
document.images["nt_0"+i].src = '../_img/1_nota_0'+i+'_off.gif';
}
}
}
thanks again for all you patience, and your help
Just one more question, to Chris Tifer, can you elaborate why should I
preffer the image collection and should avoid eval() ? So I can understand ?
TIA
Marcelo Simon
----- Original Message -----
From: "Chris Tifer" <christ at saeweb.com>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Tuesday, June 24, 2003 4:50 PM
Subject: Re: [Javascript] dynamic variables names
> Use the images collection. Avoid eval whenever possible...
>
> Did my posts not make it to the list?
>
More information about the Javascript
mailing list