Copy link to clipboard
Copied
Hi,
I'm new to javascript so please excuse me. I am trying to clear image fields on a document. Currently, the user can include an image but if they want to change it they can only replace it, they can't delete it.
I have tried three scripts below -- in both the image properties box and in a separate button --- and nothing words. I can get the scripts to clear text fields but not the image fields.
1.
if (xfa.event.shift)
{
this.rawValue = null;
}
2,
if {this.resetForm(["imageField1"]);}
3.
ImageField.rawValue = null;
Can anyone tell me what I'm doing wrong?
Thanks for any help.
Joanne
Take a look at this: Clear Image Field in PDF Form With Acrobat's JavaScript - KHKonsulting LLC
Copy link to clipboard
Copied
Do you use the LiveCycle Designer?
Copy link to clipboard
Copied
No, I'm using Acrobat Pro DC in the Prepare Form section and putting the javascript in the Properties dialogue box > Advanced.
J
Copy link to clipboard
Copied
The code at 1. and 3. is for forms created with LiveCycle Designer.
Copy link to clipboard
Copied
Oh. Shows how much I don't know! Thank you!
Do you know of a code snippet that will work with Acrobat? Or where I could go to find one?
I can get it to work on the text fields but not on the images.
J
Copy link to clipboard
Copied
You can replace it with a white image.
Copy link to clipboard
Copied
No need to use a white image, you can just use a hidden button that does not use an image, and copy the button icon from that hidden button. See here for some more details:
JavaScript for Clearing JPEGs out of a Form??? (Adobe Acrobat Pro DC)
Copy link to clipboard
Copied
Wow! Thank you both for your help. This may be beyond me -- but I'll give it a try. I'll post back on my progress.
Have a good night!
J
Copy link to clipboard
Copied
Take a look at this: Clear Image Field in PDF Form With Acrobat's JavaScript - KHKonsulting LLC
Copy link to clipboard
Copied
Thank you so much!! I followed your tutorial and the form works great. I have 58 pictures on the form so I made a button with an X label for each one. I didn't want the other form data to be cleared so I removed that part of the code.
Thanks again for all your help.
Joanne
Copy link to clipboard
Copied
I am very new to javascript and I created an interactive form with a clear form button. It will clear all text but it doesn't clear the photos from the image boxes. In reading about adding a hidden blank button to the form. I did this but I still cannot get the jpgs to clear. So I'm not adding the javascript in the blank button properly? I need some help.
Copy link to clipboard
Copied
Did you look at the page I linked to a couple of comments back? It shows you how to clear image fields.
Copy link to clipboard
Copied
Karl
I did but I’m still confused. I’ve never done anything with Javascript.
So I created a document with a Clear Form button and the Blank Button. In the Clear Form button in the properties in the Actions tab I have it set up as Reset Form.
In the Blank button is this where I add the Javascript so that when the clear form button is clicked it will clear the entire form including the images? Or do I do the Javascript in the Clear Form button?
I have two image boxes which I added the javascript of: event.target.buttonImportIcon(); and the box labels are Imag1 and Imag2.
Do I need to add (2) blank Hidden buttons one for each image box?
So in the instructions of adding javascript when it states:
1. (“Img”) for my buttons should it be Imag1?
5. ButtonSet Icon should I type in buttonImportIcon and then buttonGetIcon should I type in buttonImportIcon?
Thank you for your assistance, Hopefully I am clear as to what I am asking.
Kelli
Copy link to clipboard
Copied
The blank button is used for only one thing: a place to keep a nice blank image (called an icon), for you to do stuff with. You make it invisible (hidden) and don't add any script to it. You give it a name ("blank" in the tutorial), and use scripts on your RESET button that make any fields you want to go blank, blank. The script does that simply by taking the icon image from the field "blank" and setting it as the icon image for any other field you want to go blank.
Now please reread the tutorial and see if it makes any more sense. Worth a try.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now