Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: Sum values if any as a NULL

1. ## Sum values if any as a NULL

Hi, I have a table with some values and this part of code do a sum.
Actually I have the problem that if any value in a cell is NULL the result (the sum) i "n/a".

What's need in this code to assign a "0" value if my cell is NULL?

Code:
```if(this.p.sum){
r=this.newrow(f);
for(i;i<t.w;i++){
var j=r.cells[i];
if(this.p.sum.exists(i)){
var s=0, m=t.c[i].format||'';
for(x=0;x<this.t.l;x++){
if(t.a[x].s){s+=parseFloat(t.r[x].cells[i].innerHTML.replace(/(\\$|\,)/g,''))}
}
s=decimals(s,t.c[i].decimals?t.c[i].decimals:2);
s=isNaN(s)?'n/a':m=='\$'?s=s.currency(t.c[i].decimals):s+m;
r.cells[i].innerHTML=s
}else{r.cells[i].innerHTML='&nbsp;'}
}
}```

• Code:
```var a = null;
if (!a) {a =0}
It was always going to be a game of nutrition. - Commentator Radio Scotland

• In which part?
My value is the var "s". It's necessary to assign a null value?

• Originally Posted by guif
In which part?
My value is the var "s". It's necessary to assign a null value?
That was just an example. If the value of the variable I named a and you name s is null, change the value to 0.

if (!s) {s=0}

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•