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

Code to clear dropdown list boxes

Participant ,
Feb 19, 2018 Feb 19, 2018

Expensive,

Good afternoon.

I'm creating a form where there are several drop-down lists, each with their respective values ​​and six attachable images.
I have a clean button with the following codes:

Clear button:
- Set to reset the form and the code below to delete the photos:

this.resetForm ();
this.getField ("PHOTO 1") buttonSetIcon (this.getField ("blank") buttonGetIcon ());
this.resetForm ();
this.getField ("PHOTO 2") buttonSetIcon (this.getField ("blank") buttonGetIcon ());
this.resetForm ();
this.getField ("PHOTO 3") buttonSetIcon (this.getField ("blank") buttonGetIcon ());
this.resetForm ();
this.getField ("PHOTO 4") buttonSetIcon (this.getField ("blank") buttonGetIcon ());
this.resetForm ();
this.getField ("PHOTO 5") buttonSetIcon (this.getField ("blank") buttonGetIcon ());
this.resetForm ();
this.getField ("PHOTO 6") buttonSetIcon (this.getField ("blank") buttonGetIcon ());

A reset button with the following code:
this.resetForm ();
this.getField ("ImageButton.0") buttonSetIcon (this.getField ("blank") buttonGetIcon ());
this.getField ("ImageButton.1") buttonSetIcon (this.getField ("blank") buttonGetIcon ());

The problem is that when I click the clean button, it erases everything but the dropdown list boxes. Is there any code that wipes out the drop boxes too?

TOPICS
PDF forms
4.9K
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 ,
Feb 19, 2018 Feb 19, 2018

Do you mean to remove all the list box items? 

this.getField("mylist").clearItems();

Always check the reference:

Acrobat DC SDK Documentation

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

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 ,
Feb 19, 2018 Feb 19, 2018

When a field is reset, the value of the field is set to whatever the default value is configured to. For dropdowns, this is often the first item in the list, which is often a single blank space to indicate that a selection has not been made. If you want to remove all of the list items, you would presumably have some means for adding some back as the form is being used.

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

Friends,

Good afternoon.

I tried the code, but it did not work.
I think the best solution is to leave the first field blank (configured with the space option in the drop down list)
Each dropdown list has different items. I just wanted that when I clicked the clean button, the form would go blank so that a new form could be filled out.
But I do not think there's this condition, is there?

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 ,
Feb 20, 2018 Feb 20, 2018
LATEST

A list or dropdown field will only display what is in the item list. So, to display a blank, there has to be a blank in the list. You should make sure the blank is also set as the default value by placing the focus on that element in the Options tab. The last item with focus is the default.

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

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