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

Multiply numeric fields by user entered input

Explorer ,
Apr 23, 2017 Apr 23, 2017

Copy link to clipboard

Copied

Hello I am wondering if any one help me.. I have very simple calculation but got stuck I have more then 59 numeric fields that i wan to multiply by user entered data!!

Capture.PNG

I just want when any one enter at QUANTITY field 2 or whatever they want the last Grand total field will show 160 as the text1 price is 80.00 $, so far I have this js code but this code is work only one field.

// Get first field value, as a number

var v2 = +getField("Text2").value;

var v3 = +getField("Text3").value;

// Calculate and set this field's value to the result

event.value = 80 * (v2);

event.value = 80 * (v3);

So I want there will be text1 to text 59 in same condition

event.value = 80 * (v2);

will be change according to item price...

TOPICS
Acrobat SDK and JavaScript

Views

408

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 ,
Apr 23, 2017 Apr 23, 2017

Copy link to clipboard

Copied

Hi.

Assuming that your fields uses the Field naming convention and are named as:

price.0, price.1, price.2, etc.

and

quantity.0, quantity.1, quantity.2, etc.

and

total.0, total.1, total.2, etc.

(Or whatever name you want for "total", here the number is the only thing that matters)

Place this script as a calculation script in all "total.n" fields:

oNomChamp = this.event.target.name;

var nNumRangee = oNomChamp.substring(oNomChamp.lastIndexOf('.')+1);

nPrice = this.getField("price." + nNumRangee).value;

nQuantity = this.getField("quantity." + nNumRangee).value;

event.target.value = (nPrice * nQuantity) * 1;

Using the Field naming convention is easier and automatic when duplicating fields via: right-clic (upon a field) : Create multiples copies…

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
Explorer ,
Apr 23, 2017 Apr 23, 2017

Copy link to clipboard

Copied

LATEST

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