Skip to main content
Participant
November 15, 2023
Answered

Math Function to Java ind PDF Forms

  • November 15, 2023
  • 1 reply
  • 758 views

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 has been closed for replies.
Correct answer Nesa Nurani

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

What value did you type?

1 reply

Nesa Nurani
Community Expert
Community Expert
November 15, 2023

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 = "";

 

Participant
November 15, 2023

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?

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
November 15, 2023

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

What value did you type?