Skip to main content
Participant
August 19, 2024
Answered

How to add Dollar and Cent in separate Column and carry the whole dollar to dollar column?

  • August 19, 2024
  • 2 replies
  • 893 views

I created a form version of our business bank deposit slip to easily enter cash and check information. I then auto calculated totals from each column (1 being dollars and 2 being cents). The problem I am facing is I can't figure out a way to carry over the total from cents to dollars when the cents column is more than 0.99. Is there a formula within adobe to carry this number over and "reset" at 0.00 when passing a full dollar in the cents column?

This topic has been closed for replies.
Correct answer Nesa Nurani

Remove both calculations from "TOTAL" and "TOTAL CENTS" field, then use this as 'Custom calculation script' of "TOTAL" field:

var cents = 0, dollars = 0;

for(var i = 1; i <= 28; i++) {
 cents += Number(this.getField("Check Cents " + i).valueAsString) || 0;
 dollars += Number(this.getField("Check $ " + i).valueAsString) || 0;}

dollars += Math.floor(cents / 100);
var Rcents = cents % 100;

if (Rcents < 10)
 Rcents = "0" + Rcents;

event.value = dollars;
this.getField("TOTAL CENTS").value = Rcents;

2 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
August 20, 2024

Remove both calculations from "TOTAL" and "TOTAL CENTS" field, then use this as 'Custom calculation script' of "TOTAL" field:

var cents = 0, dollars = 0;

for(var i = 1; i <= 28; i++) {
 cents += Number(this.getField("Check Cents " + i).valueAsString) || 0;
 dollars += Number(this.getField("Check $ " + i).valueAsString) || 0;}

dollars += Math.floor(cents / 100);
var Rcents = cents % 100;

if (Rcents < 10)
 Rcents = "0" + Rcents;

event.value = dollars;
this.getField("TOTAL CENTS").value = Rcents;
PDF Automation Station
Community Expert
Community Expert
August 20, 2024

Nice work.

PDF Automation Station
Community Expert
Community Expert
August 19, 2024

The easiest way is to make one field per row, formated as a 2 decimal number, right justify the fields, and line them up so the decimal is on top of the black vertical line separating dollars and cents: