Copy link to clipboard
Copied
Hello,
im quite new to scripting in acrobat but i have to solve a problem that is above my knowledge right now.
I created a form which contains dropdown-lists and date-fields. By clicking on a button the date fields should be empty. The dropdown-lists should show a single space-sign which is an element in their element-lists. So i need a script that searches the element-lists of all the dropdown-lists for the space-sign and selecting it to be shown.
I started browsing for examples but couldn´t find anything to solve my problem.
Can anyone help me please?
To reset just some fields you can use this code:
this.resetForm(["Text1", "Text2", "Dropdown1", "Checkbox5"]);
Copy link to clipboard
Copied
What default values do you use at the dropdowns?
Copy link to clipboard
Copied
When the button is clicked the dropdown-list must show nothing. So i made an element with just a space " " and selected it as default for every list. What is the code to show this default element?
Copy link to clipboard
Copied
To set that value as the default all you need to do is click it, then close the Properties dialog. The selected item is the default one. You can test it by clearing the form, either via the Clear Form command in the application itself (Acrobat only, under More in Prepare Form mode) or using this script:
this.resetForm();
Copy link to clipboard
Copied
I already found this solution but resetting the entire form does also effect the textfields i didn´t mention earlier. I asked specifically for a solution that resets the form partially because this.resetForm() does not work for me.
By browsing a little further i found a solution for the date-fields. To reset them i have to use the command this.getField("fieldname").value = "";
I assumed that this command works the same for the dropdown-lists with ... .value = " "; since the value i want to be shown is the space-sign. I testet it but the command seems not to work for dropdown-lists.
So all i need is the wright command to set the element of the element list.
Copy link to clipboard
Copied
To reset just some fields you can use this code:
this.resetForm(["Text1", "Text2", "Dropdown1", "Checkbox5"]);
Copy link to clipboard
Copied
Thanks a lot. Works perfect 🙂
Copy link to clipboard
Copied
If space character is the default value, you can use the built-in action 'reset form' in a button.