• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Java Script for Check box to update text

Community Beginner ,
Nov 13, 2017 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 ?

TOPICS
Acrobat SDK and JavaScript , Windows

Views

441

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
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 13, 2017 Nov 13, 2017

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;

Votes

Translate

Translate
Community Expert ,
Nov 13, 2017 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.

Votes

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
community guidelines
Community Beginner ,
Nov 13, 2017 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.

Votes

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
community guidelines
Community Expert ,
Nov 13, 2017 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;

Votes

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
community guidelines
Community Beginner ,
Nov 13, 2017 Nov 13, 2017

Copy link to clipboard

Copied

LATEST

You're awesome. Thanks a million!

Votes

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
community guidelines