Copy link to clipboard
Copied
Hello,
I am currently new to the prepare forms feature and new overall to the Adobe Cloud.
I have tried to create a document in which, you can calculate the percentage of the mark you achieved on a test. For instance, scoring 20 out of 40 total marks would give a result of 50%.
For the formula, I used the following:
(Text66/Text67)*1
Text66 is the achieved score
Text67 is the total marks
At first, it worked, but as I started to add all the other text fields, it has hissy fit and now throws up the error.
Any help would be appreciated.
Many Thanks in advance.
Copy link to clipboard
Copied
When field "Text67" is empty or 0 it still tries to calculate, and you can't divide by zero so that's why error, you will have to use custom calculation script instead, and set field value to 0 if "Text67" is 0:
var t66 = Number(this.getField("Text66").valueAsString);
var t67 = Number(this.getField("Text67").valueAsString);
if(t67 === 0)
event.value = 0;
else
event.value = (t66/t67)*1;
What is the point of multiply by 1?
Copy link to clipboard
Copied
When field "Text67" is empty or 0 it still tries to calculate, and you can't divide by zero so that's why error, you will have to use custom calculation script instead, and set field value to 0 if "Text67" is 0:
var t66 = Number(this.getField("Text66").valueAsString);
var t67 = Number(this.getField("Text67").valueAsString);
if(t67 === 0)
event.value = 0;
else
event.value = (t66/t67)*1;
What is the point of multiply by 1?
Copy link to clipboard
Copied
Thank you so much, this has worked!
I know I am unsure too, why I multiplied by 1 which is the same answer.
Thank you again.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now