Skip to main content
New Participant
March 2, 2017
Answered

Clear/reset individual image fields

  • March 2, 2017
  • 3 replies
  • 5706 views

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

This topic has been closed for replies.
Correct answer Karl Heinz Kremer

Take a look at this: Clear Image Field in PDF Form With Acrobat's JavaScript - KHKonsulting LLC

3 replies

kellin54339010
New Participant
February 23, 2019

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.

Karl Heinz  Kremer
Brainiac
February 23, 2019

Did you look at the page I linked to a couple of comments back? It shows you how to clear image fields.

kellin54339010
New Participant
February 23, 2019

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

Karl Heinz  Kremer
Brainiac
March 2, 2017

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)

joanne721Author
New Participant
March 2, 2017

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

Karl Heinz  Kremer
Karl Heinz KremerCorrect answer
Brainiac
March 2, 2017
Bernd Alheit
Adobe Expert
March 2, 2017

Do you use the LiveCycle Designer?

joanne721Author
New Participant
March 2, 2017

No, I'm using Acrobat Pro DC in the Prepare Form section and putting the javascript in the Properties dialogue box > Advanced.

J

Bernd Alheit
Adobe Expert
March 2, 2017

The code at 1. and 3. is for forms created with LiveCycle Designer.