Copy link to clipboard
Copied
Hi,
I have a Report Form with a photo page like this:
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
What code are you using with the Reset button, and what is the button name?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
You missing a closing parentheses in the first line of code. It should throw an error message.
Copy link to clipboard
Copied
It was a miss typing.
Do you have Acrobat Pro?
Can I send you my form so you can verify?
Thanks
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
You must use the correct field name on the spawned pages:
this.getField("Image1").buttonSetIcon(buttonIcon);
^^^^^^
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
URDBest!!!!!!!
THANK YOU!!!!!
VERY MUCH!!!!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now