Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] dynamic variables names


  • From: grillo at lazzuri.com.br (Marcelo Simon)
  • Subject: [Javascript] dynamic variables names
  • Date: Tue Jun 24 15:03:35 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@xxxxxxxxxx>
To: "[JavaScript List]" <javascript@xxxxxxxxxx>
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?
>