cancel
Showing results for 
Search instead for 
Did you mean: 

Subtotals format in Adobe forms when using java script not displaying 00

ankit_agarwal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi All,

I am calculating subtotals in adobe forms using java script and I am using decimal field to display.

Script code:

var fields = xfa.layout.pageContent(j, "field", 0);                "Doubtful. Don't remember exact.

var total = 0;

for (var i=0; i <= fields.length-1; i++){

if (fields.item(i).name == "VALUE"){

total = parseFloat(total) + parseFloat(fields.item(i).rawValue);

}

}

this.rawValue = total;

I am getting the output as 36200 but I need it as  36200.00.

When there is decimal value in amount it gives proper output like 10.25+10.00 = 20.25.

But When I add 10.00 + 10.00, I get 20 instead of 20.00.

I tried using patterns but it’s not working. When I tried Currency pattern it is displaying $32600.00 but i don't need $ or any currency sign.

Request your help on this.

Response would be appreciated.

Thanks,

Ankit Agarwal

Accepted Solutions (1)

Accepted Solutions (1)

former_member531036
Participant
0 Kudos

Hi Ankit,

How did you format your pattern? Since our forms go out to multiple countries, we handle decimal field formatting using JavaScript. A value is passed to the form and based on that value we use the "switch" script, setting the field accordingly. For example, if two decimal places were required: this.format.picture.value = "zzz,zzz,zzz,zz9.99";

You could try that to see if it works for you.

Julie

ankit_agarwal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Thanks Julie.

It worked for me.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Ankit,

That's normal behavior for parseFloat(string), if you want it fixed to 2 decimals then do it as


parseFloat(total).toFixed(2);

Cheers,

Arshid