Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- Home
- >
- Acrobat SDK
- >
- Splitting Variables

New Here
,

Jul 18, 2019

Copy link to clipboard

Copied

I have a form with several variables created from splitting data from another numeric field. The goal is to take even numbered places and multiply by 2 and odd numbers by 1.

So, a number 5578; position 1 is 5 with 1 being an odd number would multiply by 1 for a variable value equaling 5. Position 2 is also 5, 2 being even would multiply by 2 equaling 10, and so on. At the end of the say I want to take all the equated numbers and add them together as follows based on the example: 5+1+0+7+1+6; so the variables that result in a double digit would need to split into single characters like I am doing with the original field value. I don't have any issue doing this in straight js on a web page, but I am not sure how this is done in Acrobat everything I have tried throws an error. Root question, how do I split a 2 digit variable into 2 separate variables?

The I have broken my field value out into vars such as digi1, digi2, digi3, and digi4.

In js on a webpage I can have the following:

var maths1 = digi1; //5

var maths2 = digi2 * 2; //10

var maths2p1 = Math.trunc((maths2 / 10) % 10); //1

var maths2p2 = maths2 % 10; //0

var maths3 = digi3; //7

var maths4 = digi4 * 2; //16

var maths4p1 = Math.trunc((maths4 / 10) % 10); //1

var maths4p2 = maths4 % 10; //6

then add them up using var sum1 = maths1 + maths2p1 + maths2p2 + maths3 + maths4p1 + maths4p2

and it works fine.

Part 2 of this is to take this number, (sum1) and divide it by a modulus 10, get the remainder, then subtract that remainder by the modulus.

My working web code is as follows:

var modulus = 10;

var z = Math.trunc(sum1 / modulus);

var remainder = sum1 % modulus;

z1 = modulus - remainder;

z1 becomes the final value of my field. Can someone help me translate my web code into adobe?

Thank you in advance, I have worn out Google looking for this.

Adobe Community Professional

Read this:

TOPICS

Acrobat SDK and JavaScript

Community Guidelines

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

New Here
,

Jul 18, 2019

Copy link to clipboard

Copied

I have a form with several variables created from splitting data from another numeric field. The goal is to take even numbered places and multiply by 2 and odd numbers by 1.

So, a number 5578; position 1 is 5 with 1 being an odd number would multiply by 1 for a variable value equaling 5. Position 2 is also 5, 2 being even would multiply by 2 equaling 10, and so on. At the end of the say I want to take all the equated numbers and add them together as follows based on the example: 5+1+0+7+1+6; so the variables that result in a double digit would need to split into single characters like I am doing with the original field value. I don't have any issue doing this in straight js on a web page, but I am not sure how this is done in Acrobat everything I have tried throws an error. Root question, how do I split a 2 digit variable into 2 separate variables?

The I have broken my field value out into vars such as digi1, digi2, digi3, and digi4.

In js on a webpage I can have the following:

var maths1 = digi1; //5

var maths2 = digi2 * 2; //10

var maths2p1 = Math.trunc((maths2 / 10) % 10); //1

var maths2p2 = maths2 % 10; //0

var maths3 = digi3; //7

var maths4 = digi4 * 2; //16

var maths4p1 = Math.trunc((maths4 / 10) % 10); //1

var maths4p2 = maths4 % 10; //6

then add them up using var sum1 = maths1 + maths2p1 + maths2p2 + maths3 + maths4p1 + maths4p2

and it works fine.

Part 2 of this is to take this number, (sum1) and divide it by a modulus 10, get the remainder, then subtract that remainder by the modulus.

My working web code is as follows:

var modulus = 10;

var z = Math.trunc(sum1 / modulus);

var remainder = sum1 % modulus;

z1 = modulus - remainder;

z1 becomes the final value of my field. Can someone help me translate my web code into adobe?

Thank you in advance, I have worn out Google looking for this.

Adobe Community Professional

Read this:

TOPICS

Acrobat SDK and JavaScript

Community Guidelines

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

sprank75

Jul 18, 2019
0
/t5/acrobat-sdk/splitting-variables/td-p/10579967
6
Replies
6

Adobe Community Professional
,

Jul 18, 2019

Copy link to clipboard

Copied

What errors does you get?

Community Guidelines

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

Reply

Loading...

Bernd Alheit

Jul 18, 2019
0
/t5/acrobat-sdk/splitting-variables/m-p/10579968#M10821
New Here
,

Jul 18, 2019

Copy link to clipboard

Copied

Community Guidelines

Reply

Loading...

sprank75

Jul 18, 2019
0
/t5/acrobat-sdk/splitting-variables/m-p/10579969#M10822
Adobe Community Professional
,

Jul 18, 2019

Copy link to clipboard

Copied

The function trunc is not available in Adobe Acrobat.

Community Guidelines

Reply

Loading...

Bernd Alheit

Jul 18, 2019
0
/t5/acrobat-sdk/splitting-variables/m-p/10579970#M10823
New Here
,

Jul 18, 2019

Copy link to clipboard

Copied

Community Guidelines

Reply

Loading...

sprank75

Jul 18, 2019
0
/t5/acrobat-sdk/splitting-variables/m-p/10579971#M10824
Adobe Community Professional
,

Jul 18, 2019

Copy link to clipboard

Copied

Read this:

Community Guidelines

Reply

Loading...

Bernd Alheit

Jul 18, 2019
0
/t5/acrobat-sdk/splitting-variables/m-p/10579972#M10825
sprank75
LATEST

New Here
,

Jul 18, 2019

Copy link to clipboard

Copied

Thank you so much, that did the trick.

Community Guidelines

Reply

Loading...

sprank75

Jul 18, 2019
0
/t5/acrobat-sdk/splitting-variables/m-p/10579973#M10826
Using the Community
Experience League
Terms of Use
Privacy Policy
Cookie preferences
AdChoices
Language:

- Deutsch
- English
- Español
- Français
- 日本語コミュニティ
- Português

Copyright © 2020 Adobe. All rights reserved.