Skip to main content
Participant
June 15, 2024
Answered

Script for partially resetting form

  • June 15, 2024
  • 2 replies
  • 650 views

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?

This topic has been closed for replies.
Correct answer try67

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.


To reset just some fields you can use this code:

this.resetForm(["Text1", "Text2", "Dropdown1", "Checkbox5"]);

2 replies

Nesa Nurani
Community Expert
Community Expert
June 15, 2024

If space character is the default value, you can use the built-in action 'reset form' in a button.

Bernd Alheit
Community Expert
Community Expert
June 15, 2024

What default values do you use at the dropdowns?

Participant
June 15, 2024

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?

try67
Community Expert
Community Expert
June 15, 2024

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();