method for onFocusGained

I tried to set a form method to change the bgcolor of every field without making a method for each element, but it does not work: I got error (The undefined value has no properties.) and also the debugger stucks.
Something like this:

 var thiselementname = application.getMethodTriggerElementName();
elements.thiselementname.bgcolor = '#ffff00';

I tried different codes but I obtained no result.
If I use the element name, not the var, it works properly, but there are a lot of fields…

Any suggestion?

Try:

elements[thiselementname].bgcolor = '#ffff00';

bcusick:
Try:

elements[thiselementname].bgcolor = '#ffff00';

In this case the error is:

ElementScope[indirizzo,0] is not a function.

indirizzo is the field name

Does the element have a name?

Is your method a form method and not a global method? If it’s a global methof, you also need to include the formname part:

forms[application.getMethodTriggerformName()].elements[application.getMethodTriggerElementName()
].bgcolor = ‘#ffff00’;

Does the element from which you fire your method have bgcolor as a function?

Just some thoughts…

Paul

pbakker:
Does the element have a name?

Is your method a form method and not a global method? If it’s a global methof, you also need to include the formname part:

forms[application.getMethodTriggerformName()].elements[application.getMethodTriggerElementName()
].bgcolor = ‘#ffff00’;

Does the element from which you fire your method have bgcolor as a function?

Just some thoughts…

Paul

I found my error: I used () instead of . I’m not so skilled in javascript to understand clearly the difference.
Now it works, thanks!