Skip to main content
Participant
Nov 15, 2023 10:52 AM UTC
Answered

Math Function to Java ind PDF Forms

Hi all, 

 

unfortunately my knowledge of Java Script is bareley zero. 

 

I would help how to implement a Custom Calculation Script. The situation looks like this:

 

Field A is a Value in currency

Fiel B is the output field

 

B= If Fied A <2500€; A*0,015; If Field A<5000€; A*0,0,25; IF Field A>10.000€ B="Text"

 

Could you please help me? Best case woule be if i would be able to copy it here 

 

 

 

This topic is closed to new replies. Start a new post to keep the conversation going.
Nesa Nurani
Nesa NuraniCorrect answer
Community Expert
Nov 15, 2023 11:32 AM UTC

Did you change "Field A" to your actual field name?

What value did you type?

4 replies

Nesa Nurani
Community Expert
Community Expert
Nov 15, 2023 11:14 AM UTC

Use this:

var a = Number(this.getField("Field A").valueAsString);
if(a > 0 && a < 2500)
event.value = a*0.015;
else if(a >= 2500 && a < 5000)
event.value = a*0.025;
else if(a > 10000)
event.value = "Text";
else
event.value = "";

 

Translate
Participant
Nov 15, 2023 11:27 AM UTC

Hi Nesa,

 

thx I copied the code it creates no errors but if i open the pdf and type a value into "field a" field b stays empty. Do you know why?

Translate
Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
Nov 15, 2023 11:32 AM UTC

Did you change "Field A" to your actual field name?

What value did you type?

Translate