Simple Set Field Color

Questions, tips and tricks and techniques for scripting in Servoy

Simple Set Field Color

Postby mpwiedemann » Tue Jun 17, 2003 7:17 am

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!
mpwiedemann
 
Posts: 49
Joined: Sun Jun 01, 2003 9:08 pm
Location: Seattle, WA

Postby Harjo » Tue Jun 17, 2003 8:12 am

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.
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Postby mpwiedemann » Tue Jun 17, 2003 8:26 am

Yes, the property name is set to 'emailgood' and I have tried it with and without the quotes.
mpwiedemann
 
Posts: 49
Joined: Sun Jun 01, 2003 9:08 pm
Location: Seattle, WA

Postby Ron » Tue Jun 17, 2003 10:45 am

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
Ron
 
Posts: 315
Joined: Fri May 23, 2003 12:30 am
Location: Netherlands

Postby edward » Tue Jun 17, 2003 11:15 am

Dont forget the 'return''

if ( emailgood != 1 )

{
return elements.email.bgcolor='#FF0000';

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



HTH
Edward Callaghan
Servoy
edward
 
Posts: 142
Joined: Wed Apr 23, 2003 9:35 pm
Location: London, UK

Postby Guest » Tue Jun 17, 2003 5:02 pm

Thanks guys!
Guest
 


Return to Methods

Who is online

Users browsing this forum: No registered users and 14 guests

cron