Skip to main content
Participant
Mar 2, 2017 7:03 PM UTC
Answered

Clear/reset individual image fields

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 is closed to new replies. Start a new post to keep the conversation going.
Karl Heinz  Kremer
Karl Heinz KremerCorrect answer
Community Expert
Mar 2, 2017 10:13 PM UTC

13 replies

kellin54339010
Participant
Feb 23, 2019 3:28 AM UTC

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.

Translate
Karl Heinz  Kremer
Community Expert
Community Expert
Feb 23, 2019 3:43 AM UTC

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

Translate
kellin54339010
Participant
Feb 23, 2019 4:27 PM UTC

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

Translate
Karl Heinz  Kremer
Community Expert
Community Expert
Mar 2, 2017 9:12 PM UTC

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)

Translate
joanne721Author
Participant
Mar 2, 2017 9:18 PM UTC

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

Translate
Karl Heinz  Kremer
Community Expert
Karl Heinz KremerCommunity ExpertCorrect answer
Community Expert
Mar 2, 2017 10:13 PM UTC
Bernd Alheit
Community Expert
Community Expert
Mar 2, 2017 7:37 PM UTC

Do you use the LiveCycle Designer?

Translate
joanne721Author
Participant
Mar 2, 2017 8:01 PM UTC

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

J

Translate
Bernd Alheit
Community Expert
Community Expert
Mar 2, 2017 8:49 PM UTC

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

Translate