subtotal of the fields into abc_Total

Hi All,

I have a method that gets the subtotal of the fields into abc_Total field. However, I like to have a condition such as if any of the fields is left null then no subtotal should get inserted into abc_total field.

The method name is called abc_Total

var result = Math.abs (abc_hyperactivity + abc_inappropriate_speech + abc_irritability + abc_lethargy + abc_stereotypy)
if (abc_hyperactivity != “null” && abc_inappropriate_speech != “null” && abc_irritability != “null” && abc_lethargy != “null” && abc_stereotypy != “null” && abc_hyperactivity != “null”)
{
abc_total = “null”
}

else abc_total = result

Some how the above method inserts the total into abc_Total regardless of any null fields.

Any suggestion how to make this work.

Thanks in advance,

Abrahim

akalehzan:
The method name is called abc_Total

var result = Math.abs (abc_hyperactivity + abc_inappropriate_speech + abc_irritability + abc_lethargy + abc_stereotypy)
if (abc_hyperactivity != “null” && abc_inappropriate_speech != “null” && abc_irritability != “null” && abc_lethargy != “null” && abc_stereotypy != “null” && abc_hyperactivity != “null”)
{
abc_total = “null”
}

else abc_total = result

Some how the above method inserts the total into abc_Total regardless of any null fields.

You’re not using the correct syntax for an if..else statement. Also, NEVER put quotes around “NULL”. NULL is a keyword. If you put quotes around it - it will try to evaluate to the STRING VALUE “null”, and not NULL. Try this:

var result = Math.abs (abc_hyperactivity + abc_inappropriate_speech + abc_irritability + abc_lethargy + abc_stereotypy)
 if (abc_hyperactivity && abc_inappropriate_speech && abc_irritability && abc_lethargy && abc_stereotypy && abc_hyperactivity)
{
   abc_total = null
}
else
{
   abc_total = result
}

Hope this helps,

Bob Cusick