Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Javascript - How to populate a text field with a string of text based on the selection of two dropdown lists

New Here ,
Apr 21, 2017 Apr 21, 2017

Copy link to clipboard

Copied

Greetings. I have looked all over for this solution and am hitting a wall.

I have two dropdown lists on my Adobe Acrobat DC form. Here is the pseudocode I am trying to create into a javascript action:

If (dropdownList1 value == "department1") && (dropdownList2 value == "building1") then textBox value == "Mr. Church"

else

textBox value == " "

Anyone had any luck getting something like this working?

Thanks.

[Moderator moved from non-technical forum Lounge to JavaScript .]

Nancy

TOPICS
Acrobat SDK and JavaScript

Views

843

Likes

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

Adobe Community Professional , Apr 21, 2017 Apr 21, 2017
You almost have the correct script - you just need to convert it to valid JavaScript syntax and to use the correct Acrobat API functions:var d1 = this.getField("dropdownList1").value;var d2 = this.getField("dropdownList2").value;if ((d1 == "department1") && (d2 == "building1")){    event.value = "Mr. Church";}else{    event.value = "";}When you use this as the custom calculation script in your text field, you should see the behavior you described.

Likes

Translate

Translate
Adobe Community Professional ,
Apr 21, 2017 Apr 21, 2017

Copy link to clipboard

Copied

You almost have the correct script - you just need to convert it to valid JavaScript syntax and to use the correct Acrobat API functions:

var d1 = this.getField("dropdownList1").value;

var d2 = this.getField("dropdownList2").value;

if ((d1 == "department1") && (d2 == "building1"))

{

    event.value = "Mr. Church";

}

else

{

    event.value = "";

}

When you use this as the custom calculation script in your text field, you should see the behavior you described.

Likes

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
Adobe Community Professional ,
Apr 21, 2017 Apr 21, 2017

Copy link to clipboard

Copied

BTW: If you want to learn how JavaScript works, take a look here: Learning to Program JavaScript for Adobe Acrobat - KHKonsulting LLC

Likes

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
New Here ,
Apr 21, 2017 Apr 21, 2017

Copy link to clipboard

Copied

OMG you are a lifesaver!!! This is EXACTLY what I was looking for.

Thank you! I am new to the forum, so is there any way to assign you points for this?

Likes

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
New Here ,
Jan 08, 2019 Jan 08, 2019

Copy link to clipboard

Copied

LATEST

How would you add more conditions to that for more combinations of choices?

Likes

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