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.
What errors does you get?
If I use the web code I get an invalid function Math.trunc. i have nothing to go on for splitting the variable any other war that i have found. I have not done anything as far as part 2 goes in Acrobat since part 1 is not there.
The function trunc is not available in Adobe Acrobat.
That is the purpose of my question, what would the alternative method for this be in Acrobat. How can I accomplish the same thing without this function?
Thank you so much, that did the trick.