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

Clear/reset individual image fields

New Here ,
Mar 02, 2017 Mar 02, 2017

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

TOPICS
Acrobat SDK and JavaScript
5.4K
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

correct answers 1 Correct answer

Community Expert , Mar 02, 2017 Mar 02, 2017
Translate
Community Expert ,
Mar 02, 2017 Mar 02, 2017

Do you use the LiveCycle Designer?

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 02, 2017 Mar 02, 2017

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

J

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 02, 2017 Mar 02, 2017

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

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 02, 2017 Mar 02, 2017

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

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 02, 2017 Mar 02, 2017

You can replace it with a white image.

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 02, 2017 Mar 02, 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)

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 02, 2017 Mar 02, 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

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 02, 2017 Mar 02, 2017
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 03, 2017 Mar 03, 2017

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

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 22, 2019 Feb 22, 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.

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 ,
Feb 22, 2019 Feb 22, 2019

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

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 23, 2019 Feb 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

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 23, 2019 Feb 23, 2019
LATEST

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.

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