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

Script for partially resetting form

New Here ,
Jun 15, 2024 Jun 15, 2024

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?

TOPICS
Windows

Views

418

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

correct answers 1 Correct answer

Community Expert , Jun 16, 2024 Jun 16, 2024

To reset just some fields you can use this code:

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

Votes

Translate

Translate
Community Expert ,
Jun 15, 2024 Jun 15, 2024

Copy link to clipboard

Copied

What default values do you use at the dropdowns?

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
New Here ,
Jun 15, 2024 Jun 15, 2024

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?

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 ,
Jun 15, 2024 Jun 15, 2024

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

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
New Here ,
Jun 16, 2024 Jun 16, 2024

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.

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 ,
Jun 16, 2024 Jun 16, 2024

Copy link to clipboard

Copied

To reset just some fields you can use this code:

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

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
New Here ,
Jun 17, 2024 Jun 17, 2024

Copy link to clipboard

Copied

LATEST

Thanks a lot. Works perfect 🙂

 

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 ,
Jun 15, 2024 Jun 15, 2024

Copy link to clipboard

Copied

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

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