Javascript Problem

Hi everybody,

I’m am newbie in scriptcase and try a lot of things to develop an application.
If I well understand, we can’t use sc_field_color of sc_field_style within a form application even this application use a multiple rows.
So I have to use javascript … (heu …java what ???)

Let me present the problem :

  • I have a master/detail form with :
  • in the master, a field (MaxFat) that I need to use in the detail form.
  • In the detail form, a field (ActualFat) that it must be in red or in green depending if its value exceed the value of the MaxFat field.

These two fields are declared as decimal (5,2) in MySql.

Exemple : ActualFat in red if its value > MaxFat and ActualFat in green if its value is under MaxFat

I defined in the detail form (Javascript) , an event (on blur) for the field ActualFat in order to change dynamically the color when I leave this field according the rule indicated before.

So, this the javascript I put in this event :

if (document.F1.ActualFat.value > MaxFat)
{
document.F1.ActualFat.style.BgColor = “FF0000”; //red
}
else
{
document.F1.ActualFat.style.BgColor = “00800”; // green
}

Questions :

  1. Nothing happen when I leave the field “ActualFat”, do you know why ?
  2. Is it normal to name “F1” the form or do I have to give the name of the form in scriptcase?
  3. How can I compare correctly the 2 fields due to the fact they are both decimals (5,2)?

Thank you very much for your help.

Regards,
Jean-Fran?ois.

try it in an onchange event. secondly try using document.getElementsbyName(“ActualFat”).style.bgcolor.

Remember that if you name your field ActualFat in scriptcase that name wont be the same at execution time… try using chrome inspect utility to verify the actual name of the field.

Regards