views:

36

answers:

1

I'm trying to set properties of some elements through a for loop, but am confused about the implementation.

Here is the code:

var fiArray = new Array('name','address','address2','phone','fax','misc1','misc2');

function disableFields(){
   for(i=0,x=fiArray.length; i < x; i++){
       var disEl = "$('formID')."+fiArray[i];
       disEl.disabled=true;
   }

}

I've tried every permutation of changing the disEl var, not using a var, concatenating different parts of the disEl string; nothing seems to work.

I know I'm missing something simple and fundamental here...

p.s. using prototype

+2  A: 
var disEl = $('formID')[fiArray[i]];
Amarghosh
I knew that... I was just seeing if this place had any Moxy ;)Thanks!
stormdrain