Java Script for Check box to update text

Nov 13, 2017

Copy link to clipboard

Copied

Hello,

I have 1 checkbox with the name taxable and 2 fields with the name CashPrice and TaxableTotal. And in text1 there is a value.

Now comes my question if i check the checkbox the value of CashPrice needs to be added to the TaxableTotal. There are 8 lines that will needed to be able to be added. I don't know how to begin.

Can someone help me with this script ?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

OK, that's better. You can use this code as the custom calculation script of your total field:

var total = 0;

for (var i=1; i<=8; i++) {

    if (this.getField("Taxable"+i).value!="Off")

        total+=Number(this.getField("CashPrice"+i).value);

}

event.value = total;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

142

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

Java Script for Check box to update text

Nov 13, 2017

Copy link to clipboard

Copied

Hello,

I have 1 checkbox with the name taxable and 2 fields with the name CashPrice and TaxableTotal. And in text1 there is a value.

Now comes my question if i check the checkbox the value of CashPrice needs to be added to the TaxableTotal. There are 8 lines that will needed to be able to be added. I don't know how to begin.

Can someone help me with this script ?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

OK, that's better. You can use this code as the custom calculation script of your total field:

var total = 0;

for (var i=1; i<=8; i++) {

    if (this.getField("Taxable"+i).value!="Off")

        total+=Number(this.getField("CashPrice"+i).value);

}

event.value = total;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

143

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
Nov 13, 2017 1
Most Valuable Participant ,
Nov 13, 2017

Copy link to clipboard

Copied

It's possible, but you need to better explain the situation... Where does "text1" fit into this? What are the names of the 8 fields? Is it 8 pairs of check-boxes and text fields, or something else? Please clarify.

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...
Nov 13, 2017 0
Nov 13, 2017

Copy link to clipboard

Copied

I apologize in CashPrice there is a value... text1 doesn't fit in this one that was an accident. It is 8 pairs of check boxes and fields. The check boxes are named Taxable1, Taxable2, Taxable3....Taxable8 the text fields are CashPrice1, CashPrice2....CashPrice8.

This is a form used for a purchase order. My goal is to find the total of the equipment that is taxable, so that I can figure the tax in a later box.

By trial and error and lots of reading I have figured out several of the other scripts that I have used, but this one has stumped me.

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...
Nov 13, 2017 0
Most Valuable Participant ,
Nov 13, 2017

Copy link to clipboard

Copied

OK, that's better. You can use this code as the custom calculation script of your total field:

var total = 0;

for (var i=1; i<=8; i++) {

    if (this.getField("Taxable"+i).value!="Off")

        total+=Number(this.getField("CashPrice"+i).value);

}

event.value = total;

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...
Nov 13, 2017 0
Nov 13, 2017

Copy link to clipboard

Copied

You're awesome. Thanks a million!

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...
Nov 13, 2017 0