Code to clear dropdown list boxes
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Do you mean to remove all the list box items?
this.getField("mylist").clearItems();
Always check the reference:
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Use the Acrobat JavaScript Reference early and often

