• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
1

Can I hide and unhide the picture using button?

New Here ,
May 26, 2022 May 26, 2022

Copy link to clipboard

Copied

one Button created. also imported .png file. When I click the button It hide the picture and When I click the button again it unhide the picture.    (I want to do like that)   How can I do? plz help me!

 

Screenshot 2022-05-27 104729.png

 
TOPICS
How to , JavaScript

Views

2.1K

Translate

Translate

Report

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 2 Correct answers

Community Expert , May 26, 2022 May 26, 2022

In 'Prepare form' tool you can add 'image field' close 'Prepare form' and click on that field to import image.

Now in  a button as 'Mouse UP' event, select 'Run a JavaScript' and enter this script and make sure field name is same as your actual field name:

this.getField("Image1_af_image").display = this.getField("Image1_af_image").display == display.visible ? display.hidden : display.visible;

Votes

Translate

Translate
Community Expert , May 27, 2022 May 27, 2022

The only way to hide an image with a script is if that image is the icon of a button field, or if you use a button (or any other type of field) to hide it underneath it. Either way, it will require using a script, like the one Nesa provided above.

Just to clarify, though, when the image is hidden there will be a white gap on the page. It will not cause the rest of the page's contents to "reflow" and fill that gap.

Votes

Translate

Translate
Community Expert ,
May 26, 2022 May 26, 2022

Copy link to clipboard

Copied

In 'Prepare form' tool you can add 'image field' close 'Prepare form' and click on that field to import image.

Now in  a button as 'Mouse UP' event, select 'Run a JavaScript' and enter this script and make sure field name is same as your actual field name:

this.getField("Image1_af_image").display = this.getField("Image1_af_image").display == display.visible ? display.hidden : display.visible;

Votes

Translate

Translate

Report

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 ,
Jun 11, 2022 Jun 11, 2022

Copy link to clipboard

Copied

Thanks.

 

Votes

Translate

Translate

Report

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 Beginner ,
Jan 11, 2023 Jan 11, 2023

Copy link to clipboard

Copied

This works great. I'm a little disappointed that I need to click away first and then click again to toggle the image.

I tried one time to add a few more lines to the same javascript

 

this.getField("Circled.1").display = this.getField("Circled.1").display == display.visible ? display.hidden : display.visible;
this.getField("Circled.2").display = this.getField("Circled.2").display == display.visible ? display.hidden : display.visible;
this.getField("Circled.3").display = this.getField("Circled.3").display == display.visible ? display.hidden : display.visible;

 

And so, I click once and circled.1 displays. I click again, circled.1 disappears and Circled.2 and Circled.3 appear at the same time. Ugh...surely I can set up a single button - to "draw a circle around the day of the week"?  The form should only have one of the 7 days circled.

 

Thanks again.

 

 

Votes

Translate

Translate

Report

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 ,
Jan 11, 2023 Jan 11, 2023

Copy link to clipboard

Copied

Perhaps if you share your file and describe the workflow you wish to achieve, we can probably help.

Votes

Translate

Translate

Report

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 Beginner ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

LATEST

Nessa,

Thank you for responding. I saw your request to share and with great senility shared on another post. I would love to resolve this. I only just now found this again. I'm wondering if I'm in two different support sites and that is why I am confused? Sorry. If you are okay, I would like to pursue this further. I just need to go sit at my desk and review this and upload. 

Votes

Translate

Translate

Report

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 ,
May 27, 2022 May 27, 2022

Copy link to clipboard

Copied

The only way to hide an image with a script is if that image is the icon of a button field, or if you use a button (or any other type of field) to hide it underneath it. Either way, it will require using a script, like the one Nesa provided above.

Just to clarify, though, when the image is hidden there will be a white gap on the page. It will not cause the rest of the page's contents to "reflow" and fill that gap.

Votes

Translate

Translate

Report

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