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

Create a Reset button to clear images

New Here ,
Feb 28, 2018 Feb 28, 2018

Hi,

I have a Report Form with a photo page like this:

Pfoto Add.jpg

I create a hidden Photo Template Page to be added as a new page below the original for add more pictures.

The reset button to "clear image" that really replace the icon works great. But when I add it as a "New Page" the reset button didn't work.

I know that is because of the field name that is attached in the form.

My question is, There is a javascript or another way to resolve this issue?

I will appreciate any help.

Thanks

TOPICS
PDF forms
3.8K
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
1 ACCEPTED SOLUTION
Community Expert ,
Mar 09, 2018 Mar 09, 2018

First of all, you should not be adding two separate "Run a JavaScript" command. Use only one for each button.

Since the names of the fields on the spawned page are predictable you can use a simple replace command to change the name of the button to the name of the field. So, for example, for the first set of fields it will be:

var buttonIcon = this.getField("Click here").buttonGetIcon();

this.getField(event.target.name.replace("blank", "Image1")).buttonSetIcon(buttonIcon);

Edit: code fixed

View solution in original post

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

What code are you using with the Reset button, and what is the button name?

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
New Here ,
Feb 28, 2018 Feb 28, 2018

Hi,

The reset button have 2 scripts;

1. var buttonIcon = this.getField("Click here").buttonGetIcon():

2. this.getField("Image1").buttonSetIcon(buttonIcon);

There is another hidden button with name "Click here" with the Icon.

Thanks

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

It sounds like the fields are renamed when the template is spawned and the new page is created. In such a case, you can determine what field name you should use in that second line of code based on the name of the reset button. The reset button will have a name like this: P2.template_name.reset3

where template_name is the actual name of the template that was spawned and "reset3" is the name of the reset button. So the script could be modified to:

var sPage = event.target.name.split(".")[0];

getField(sPage + ".template_name.reset3").buttonSetIcon(buttonIcon);

Note that this same code won't work with the fields on the template page since it was not created by spawning a template, so it's fields would not have been renamed. This isn't intended to be the final working script, but rather to explain how fields are renamed and how the names of the renamed fields can be determined. If you get stuck, post again.

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
New Here ,
Mar 05, 2018 Mar 05, 2018

I am trying to do this code, but nothing happens.

This is the code for New Page Button:

var expTplt = getTemplate("Photo Site ADD";

expTplt.spawn({nPage: pageNum + 1, bRename: true, bOverlay: false});

Thanks for you help

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 ,
Mar 05, 2018 Mar 05, 2018

You missing a closing parentheses in the first line of code. It should throw an error message.

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
New Here ,
Mar 05, 2018 Mar 05, 2018

It was a miss typing.

Do you have Acrobat Pro?

Can I send you my form so you can verify?

Thanks

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 ,
Mar 05, 2018 Mar 05, 2018

You can upload it to a file-sharing website (Dropbox, Google Drive, Adobe Cloud, etc.) and post the link to it here.

If you want to send it to me privately you can do so to try6767 at gmail.com.

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
New Here ,
Mar 06, 2018 Mar 06, 2018
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 ,
Mar 06, 2018 Mar 06, 2018

You must use the correct field name on the spawned pages:

this.getField("Image1").buttonSetIcon(buttonIcon);

                       ^^^^^^

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
New Here ,
Mar 09, 2018 Mar 09, 2018

Yes, but when the page is spawned the field names changes too. So I need that the reset button recognize that name fields in the spawned page.

Thanks

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 ,
Mar 09, 2018 Mar 09, 2018

First of all, you should not be adding two separate "Run a JavaScript" command. Use only one for each button.

Since the names of the fields on the spawned page are predictable you can use a simple replace command to change the name of the button to the name of the field. So, for example, for the first set of fields it will be:

var buttonIcon = this.getField("Click here").buttonGetIcon();

this.getField(event.target.name.replace("blank", "Image1")).buttonSetIcon(buttonIcon);

Edit: code fixed

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
New Here ,
Mar 13, 2018 Mar 13, 2018
LATEST

URDBest!!!!!!!

THANK YOU!!!!!

VERY MUCH!!!!

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