• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Acrobat 9 Javascript Pulldown Menu if then

Community Beginner ,
Jan 24, 2019 Jan 24, 2019

Copy link to clipboard

Copied

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

TOPICS
Acrobat SDK and JavaScript

Views

330

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 24, 2019 Jan 24, 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);

}

Votes

Translate

Translate
Community Expert ,
Jan 24, 2019 Jan 24, 2019

Copy link to clipboard

Copied

LATEST

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);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines