Simple Set Field Color

Hi,

This is driving me nuts and I feel like an idiot. I’m simply trying to set the background color of a field based on the contents of another field. Here is my form method code.


if( emailgood != “1”)
{
elements.email.bgcolor = “#FF0000”;
}
else
{
elements.email.bgcolor = “#FFFFFF”;
}


The field emailgood will have either a ‘1’ or a ‘0’. I keep getting an error that says the field ‘emailgood’ is not defined. This should be simple!

Thanks!

Is the property-name of field: emailgood, set to: emailgood?

Correct me if I’m wrong, but “1” doesn’t have to be between quotes.
Between quotes means text.

Yes, the property name is set to ‘emailgood’ and I have tried it with and without the quotes.

HJK means (of course) that the property name of the field
email.bgcolor is set, not the other field.
If this is done, the field shows up as an element in
the method editor (refresh first).
I guess you did’nt check this and direcly put the code in the editor.
BTW, same example works fine with me.

Hope it helps.

Ron

Dont forget the ‘return’’

if ( emailgood != 1 )

{
return elements.email.bgcolor=‘#FF0000’;

}
else
{
return elements.email.bgcolor=‘#FFFFFF’;}

HTH

Thanks guys!