Copy link to clipboard
Copied
I'm stuck and not sure how to proceed, I split decimal to calculate but it joins numbers as string instead of calculating them, here is code I use
var c = 0;
for (var i=1; i<=3; i++) {
var a = this.getField("Text"+i).value.split(".");
var c = a[0]+i;}
event.value = c;
Try like this:
var c = 0;
for (var i=1; i<=3; i++) {
var a = this.getField("Text"+i).valueAsString.split(".");
if(this.getField("Text"+i).value != "")
c +=Number(a[0]);}
event.value = c;
Copy link to clipboard
Copied
What want you calculate?
Copy link to clipboard
Copied
I'm trying to split decimal number and then sum whole number separate and decimals separate,
Copy link to clipboard
Copied
What happens if you use instead .valueAsString
Copy link to clipboard
Copied
It doesn't change anything, I made a mistake above, I thought it show them as string because in first field I had same number as number of fields but actually it doesn't show them as string it's just number of fields and number in last field joined together.
Copy link to clipboard
Copied
Try like this:
var c = 0;
for (var i=1; i<=3; i++) {
var a = this.getField("Text"+i).valueAsString.split(".");
if(this.getField("Text"+i).value != "")
c +=Number(a[0]);}
event.value = c;