on 06-08-2016 5:07 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.