Skip to main content
Participant
December 6, 2019
Question

Help with java script for adobe a pdf form

  • December 6, 2019
  • 2 replies
  • 437 views

Good Morning.  I am trying to figure out how to get a field to automatically populate a value using java script with an if then statement.  I want it to look at the value of two other fields and return which is the highest, below is the code i have been using. Any and all help is appreciated.  I have tried it on both the calculations tab with custom java script and on the Actions tab but am unsure which trigger to use and which is correct.

 

if(this.getField("EXV").value > this.getField("CFMV").value){

event.value = EXV

} else {

Event.value = CFMV

}

 

 

[Moderator moved the thread to the correct forum]

This topic has been closed for replies.

2 replies

Inspiring
December 6, 2019

JavaScript is case sensative. You cannot have the value of an event wrtitten as "Event.value" and "event.value".

Bernd Alheit
Community Expert
Community Expert
December 6, 2019

Try this:

var EXV = Number(this.getField("EXV").valueAsString);
var CFMV = Number(this.getField("CFMV").valueAsString);
if(EXV > CFMV) {
  event.value = EXV;
} else {
  event.value = CFMV;
}