## Need Help Writing Code :( Very New At This

New Here ,
Aug 24, 2017

Copied

Can someone tell me how to write a calculation script for this.  Im adding my "Dental" field and "Health" to get the "Total",  Then to the right, there are two fields for "6100" and "1150" (just accounting codes). Anyway, If the "Total" is \$784.96 or something, how can i make the first \$300 go in the "6100" field and the remaining balance go into the "1150 box?   Thanks Guys!

Most Valuable Participant
| Most Valuable Participant

Enter this code as the custom calculation script for "6100":

var cutoff = 784.96;

var total = Number(this.getField("Total").value);

if (total>cutoff) {

event.value = cutoff;

this.getField("1150").value = total-cutoff;

} else {
event.value = total;

this.getField("1150").value = 0;
}

TOPICS
Acrobat SDK and JavaScript

Views

89

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

## Need Help Writing Code :( Very New At This

New Here ,
Aug 24, 2017

Copied

Can someone tell me how to write a calculation script for this.  Im adding my "Dental" field and "Health" to get the "Total",  Then to the right, there are two fields for "6100" and "1150" (just accounting codes). Anyway, If the "Total" is \$784.96 or something, how can i make the first \$300 go in the "6100" field and the remaining balance go into the "1150 box?   Thanks Guys!

Most Valuable Participant
| Most Valuable Participant

Enter this code as the custom calculation script for "6100":

var cutoff = 784.96;

var total = Number(this.getField("Total").value);

if (total>cutoff) {

event.value = cutoff;

this.getField("1150").value = total-cutoff;

} else {
event.value = total;

this.getField("1150").value = 0;
}

TOPICS
Acrobat SDK and JavaScript

Views

90

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 24, 2017 0
2 Replies 2
Most Valuable Participant ,
Aug 24, 2017

Copied

Enter this code as the custom calculation script for "6100":

var cutoff = 784.96;

var total = Number(this.getField("Total").value);

if (total>cutoff) {

event.value = cutoff;

this.getField("1150").value = total-cutoff;

} else {
event.value = total;

this.getField("1150").value = 0;
}

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 24, 2017 1
LATEST
New Here ,
Aug 24, 2017