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

Need help with Dropdown menu and Textbox JavaScript (Adobe Acrobat DC)

Community Beginner ,
Sep 30, 2019 Sep 30, 2019

Hello.

 

I have a Dropdown1 menu with values: 1, 2, 3, 4. And Textbox1.

 

I need that when user select 1 in the dropdown menu, the text field is 10,

when user select 2 in the dropdown menu, the text field is 15,

when user select 3 in the dropdown menu, the text field is 20,

when user select 4 in the dropdown menu, the text box was 25.

 

I am using Java code in Textbox1:

var e = this.getField("Dropdown1").valueAsString;

if (e=="1"){

event.value = "10";

if (e=="2"){

event.value = "15";

if (e=="3"){

event.value = "20";

if (e=="4"){

event.value = "25";

} else event.value = "N/A";

 

But when using this code an error occurs. How to fix the code?

 

Thank you.

932
Translate
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
LEGEND ,
Sep 30, 2019 Sep 30, 2019

What error? Please show exactly. Also please don’t call it Java, that’s very confusing! Thanks. 

Translate
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
Community Beginner ,
Sep 30, 2019 Sep 30, 2019

Hello.

Screen 268.pngSyntaxError: missing } in compound statement 19: in line 20

Translate
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
Community Expert ,
Sep 30, 2019 Sep 30, 2019

You can also do it less complicated and assign those values directly in the dropdown field "Properties"--->"Options"

 

In that tab, there is an export value field underneath the blank "Item" field where you enter the name for a listed item. Here is where you assign the export value for each listed item.

 

Then on the text field insert this line in custom calculation script: 

 

event.value = this.getField("Dropdown1"). value;

 

Don't forget to check the option that says commit selected value immediately in Dropdown1 field.

Translate
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
Community Expert ,
Sep 30, 2019 Sep 30, 2019
I apologize I didnt mean to jump over the guidance of Test Screen Name, seems like I was typing at the same time
Translate
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
Community Expert ,
Sep 30, 2019 Sep 30, 2019

You have only one } for four {

Translate
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
Community Beginner ,
Sep 30, 2019 Sep 30, 2019
LATEST
Hello Bernd. Thank you. All is OK
Translate
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