Skip to main content
Participant
January 24, 2019
Answered

Acrobat 9 Javascript Pulldown Menu if then

  • January 24, 2019
  • 1 reply
  • 487 views

Im building a spreadsheet for a gaming character sheet and Im having trouble implementing a javascript to do an "if-then command.

I have a pulldown list and I need a text field box to refer to which selection was made and then implement one math problem (adding up separate fields) or another.

For example under Race Pulldown there is Human or Halfling. If they pick Human then text field box needs to show the total calculation result of text field A+B. If it shows Halfling then it needs to show the result of text field A+C.

I tried using:

if (this.getField("Race Pulldown").value == "Halfling"){  

event.target.display = display.visible;

}

else{

event.target.display = display.hidden;

}

and replacing event.targeting.display with the math calculation but I couldnt get it to work

Thanks

Chad

This topic has been closed for replies.
Correct answer try67

Try this code:

if (this.getField("Race Pulldown").value == "Halfling"){

    event.value = Number(this.getField("A").valueAsString) + Number(this.getField("C").valueAsString);

} else {

    event.value = Number(this.getField("A").valueAsString) + Number(this.getField("B").valueAsString);

}

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
January 25, 2019

Try this code:

if (this.getField("Race Pulldown").value == "Halfling"){

    event.value = Number(this.getField("A").valueAsString) + Number(this.getField("C").valueAsString);

} else {

    event.value = Number(this.getField("A").valueAsString) + Number(this.getField("B").valueAsString);

}