How to test whether a drop down box is empty

Explorer ,
Jan 31, 2019

Copy link to clipboard

Copied

Good evening I am attempting to create large if-then structured built into Functions.

However, I am running into the problem of not being able to write IF-ELSE statements, when the argument is whether a drop-box is empty, or not.

Here is an example:

var dropBox = this.getField("Drop Box)";

var SourceField = this.getField("Source");

if (dropBox.valueAsString != "") {

  console.println(sourceField);

}

Even if Drop Box has no strings selected, it still won't complete the statement.

Any help would be greatly appreciated!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Then it should work if that value is selected... What is the outcome of running this code?

TOPICS
Acrobat SDK and JavaScript, Windows

Views

136

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

How to test whether a drop down box is empty

Explorer ,
Jan 31, 2019

Copy link to clipboard

Copied

Good evening I am attempting to create large if-then structured built into Functions.

However, I am running into the problem of not being able to write IF-ELSE statements, when the argument is whether a drop-box is empty, or not.

Here is an example:

var dropBox = this.getField("Drop Box)";

var SourceField = this.getField("Source");

if (dropBox.valueAsString != "") {

  console.println(sourceField);

}

Even if Drop Box has no strings selected, it still won't complete the statement.

Any help would be greatly appreciated!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Then it should work if that value is selected... What is the outcome of running this code?

TOPICS
Acrobat SDK and JavaScript, Windows

Views

137

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
Jan 31, 2019 0
Most Valuable Participant ,
Jan 31, 2019

Copy link to clipboard

Copied

What's the default value of the drop-down?

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
Reply
Loading...
Jan 31, 2019 0
Explorer ,
Jan 31, 2019

Copy link to clipboard

Copied

The drop-box has a blank entry as its default

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
Reply
Loading...
Jan 31, 2019 0
Most Valuable Participant ,
Jan 31, 2019

Copy link to clipboard

Copied

Then it should work if that value is selected... What is the outcome of running this code?

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
Reply
Loading...
Jan 31, 2019 1
Explorer ,
Jan 31, 2019

Copy link to clipboard

Copied

The full code is supposed to scan through 7 different drop box fields.  For every first drop box field that is empty, the "Source" variable will be put into the first available drop box field.

I want to be able to scan for which ones are empty, or not, that way nothing gets over-written in the drop box fields.

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
Reply
Loading...
Jan 31, 2019 0