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

drop down selection

Participant ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

I have 2 dropdowns.

and a submit button.

I want it to test if an item from the drop downs were selected.

The option displaying is 'Click for more options'

So check to see if it says 'Click for more options' ---- if 'Click for more options' is still showing, generate a message to say, please choose from the list.

Because these fields are required, it needs to test for a valid selection....

TOPICS
PDF forms

Views

630

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
1 ACCEPTED SOLUTION
Community Expert ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

Setting event.rc as false won't work. You need to remove the Submit Form command and do it all in your script.

View solution in original post

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 ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

If a field is marked as  "required", then the submit is blocked when it's value matches the default value. So this is one way to block the submit, i.e. set the dropdown default value to  "Click for more options".

But to display an alert message a script will need to be used to test the dropdown.

Add a "run a script" action to the submit button. Here's a sample:

if(this.getField("dropdown").value == "Click for more options")

   app.alert("Please choose an option from the dropdown");

You'll also need to either perform the submit in the same script or set the dropdown default value to "Click for more options" to block the submit.

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 ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

Hi, I have this and it works except, in the actions tab, I have the submit form, it still activates after clicking ok on the msg box. Did I forget to close something. I am also using it on 2 dropdowns.

if (this.getField("typeofestablishment").valueAsString=="click for more options") { 

         app.alert("Please select a valid Choice Number 5"); 

         event.rc = false;

}

else if (this.getField("typeoflossortheft").valueAsString=="click for more options")  {

app.alert("Please select a valid Choice Number 6");

event.rc = false;

}

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 ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

Setting event.rc as false won't work. You need to remove the Submit Form command and do it all in your script.

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 ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

LATEST

I will give it a try.

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