Need Help Writing Code :( Very New At This

New Here ,
Aug 24, 2017

Copy link to clipboard

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!
ScreenHunter_425 Aug. 24 15.52.jpg

Most Valuable Participant
Correct answer by try67 | 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

Translate

Translate

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

Copy link to clipboard

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!
ScreenHunter_425 Aug. 24 15.52.jpg

Most Valuable Participant
Correct answer by try67 | 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

Translate

Translate

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
Most Valuable Participant ,
Aug 24, 2017

Copy link to clipboard

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

Translate

Translate

Report

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

Copy link to clipboard

Copied

Worked!!! Thanks!!!!  

Likes

Translate

Translate

Report

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