Click to See Complete Forum and Search --> : access components through string variable


adema_
03-13-2003, 06:51 AM
hi!
i have a string variable that holds the name of a component and i want access this component like this:

document.form1.[componentname].disabled=true

componentname is the string variable.

thanks in advance

khalidali63
03-13-2003, 06:57 AM
there are multiple ways to do this. here is one way

var obj = eval('document.form1.'+componentName);
obj.disabled = true;

Cheers

Khalid

gil davis
03-13-2003, 07:01 AM
Originally posted by adema_
document.form1.[componentname].disabled=trueShould bedocument.form1[componentname].disabled = true;You had one too many dots.

adema_
03-13-2003, 07:09 AM
thx for your quick reply. i tried it and of course it worked.
thx very much