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

Is a drop-down window considered a string?

Participant ,
Feb 07, 2018 Feb 07, 2018

Copy link to clipboard

Copied

I ask this because I have and if/then statement set up where if a field has a keyword inputted, then when a submit button is pushed it will send an email to one of two groups.  I'm changing it because users are not "reading" the instructions and half the time, are not putting in the keyword when they should be so it's being emailed to the wrong group.

So I want to change the "if/then" to a different field but that field is a drop-down menu and it doesn't work with the ".valueAsString.indexOf("Keyword") == 0.

Here's part of what I'm working with:

var keyWord = (this.getField("Org").valueAsString.indexOf("Company Name") == 0);

if (this.getField("Signature").value != "" && keyWord == true) {

    this.mailDoc({bUI:true, cTo:sendTo, cCc:copyTo...

I have to run this script in the Button Field.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

347

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

Participant , Feb 07, 2018 Feb 07, 2018

The "Keyword" should've been "Company Name"...sorry.

Votes

Translate

Translate
Participant ,
Feb 07, 2018 Feb 07, 2018

Copy link to clipboard

Copied

The "Keyword" should've been "Company Name"...sorry.

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
Community Expert ,
Feb 07, 2018 Feb 07, 2018

Copy link to clipboard

Copied

the value of a dropdown is a string in the same sense that all field values are strings. If you use the "field.valueAsString" property it's guaranteed.

If the code is not working, it has nothing to do with whether or not the dropdown value is a string. The most likely issue are the values returned by the drop down.  I'm assuming that the dropdown is named "Org"?

To find out the value returned from the dropdown, run this code from the console window:

this.getField("Org").value

You'll find a tutorial on the Console Window here:Free Video Content & Full Listing of Available Videos

I'd also suggest rewriting the if statement to make the conditions more explicit

Like this:

if ((this.getField("Signature").value != "") && keyWord) {

is it not necessary to test a boolean for "true", since its already true or false.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Participant ,
Feb 07, 2018 Feb 07, 2018

Copy link to clipboard

Copied

LATEST

That worked Thom!  Thank you sir!

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