subtotal of the fields into abc_Total

Release notes for Servoy betas

subtotal of the fields into abc_Total

Postby akalehzan » Tue Oct 19, 2004 7:30 pm

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
 
Posts: 267
Joined: Mon Mar 29, 2004 8:15 am
Location: Stanford

Re: subtotal of the fields into abc_Total

Postby bcusick » Wed Oct 20, 2004 7:50 pm

akalehzan wrote: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:

Code: Select all
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
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA


Return to Latest Releases

Who is online

Users browsing this forum: No registered users and 17 guests

cron