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

Can I hide and unhide the picture using button?

New Here ,
May 26, 2022 May 26, 2022

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.pngexpand image

 
TOPICS
How to , JavaScript
3.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
2 ACCEPTED SOLUTIONS
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;

View solution in original post

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 ,
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.

View solution in original post

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 ,
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;

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

Thanks.

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

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.

 

 

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

Perhaps if you share your file and describe the workflow you wish to achieve, we can probably 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 Beginner ,
Jan 26, 2023 Jan 26, 2023
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. 

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 ,
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.

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