Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Image Field can't be invisible initially?

Avatar

Level 1

I have a dropdown which changes which on change displays a different image. While it does work as expected, I do not want any of the images to be visible until you've chosen from the drop down.

Problem is that if I make the images invisible (using presence) to start, they never display again. I've tried setting them to invisible both through the field tab and also in the script editor.

Anyone have any ideas?

1 Accepted Solution

Avatar

Correct answer by
Level 7

Rather than set it to invisible in the first place, how about leaving it visible with a picture in it that matches the form background to start?

View solution in original post

9 Replies

Avatar

Level 7

Are you setting the field back to visible when the user exits the drop down?

Avatar

Correct answer by
Level 7

Rather than set it to invisible in the first place, how about leaving it visible with a picture in it that matches the form background to start?

Avatar

Level 10

Hi,

If you are using image objects you could put script in the dropdown's docReady event:

image1.presence = "hidden";

image2.presence = "hidden";

...

If you are using imageFields, then you can put similar script in each of the imageFields' docReady event:

this.presence = "hidden";

On the change event of the dropdown I presume you are using the newText value and changing the presence to "visible".

Hope that helps,

Niall

Avatar

Level 1

That's pretty much what I was doing, the problem being that if 'presence' were set on anything like a form:ready, docReady etc... it would hide fine, but would never reappear when you selected it in the dropdown.

It would however come back if I made it invisible on something like a click event.

Appears there's some kinda timing issue with when you can hide an object and still be able to manipulate it later.

Avatar

Level 1

Thanks. Yeah so the solution was to create another image field fill it with a white gif and place it overtop of the other images.

Then in the onchange event of the dropdown i set: whitecover.presence = "invisible";

Avatar

Level 10

Hi,

Haven't seen that before. Normally the docReady event is good, because you are guaranteed that it will fire only once when the form opens. Are the images on the master page?

There must be something else going on; because the .presence method normally works without a hiccup. Try opening the java console in Acrobat (Control+J) and open the form and change the dropdown, to see if any errors are showing up.

Good luck,

Niall

Avatar

Level 1

Didn't see any errors. Have attached a test file showing the problem.

If you remove this.pressence = "invisible" from the imagefield docReady event, the toggle works.

Avatar

Level 10

Hi,

The main problem is that the form was saved as static. It needs to be saved as dynamic for hiding and showing objects. In the orinigal form the toggle wasn't completely hiding the object as the caption was still visible.

Nice photo ;-)

Give this a try,

Niall

Avatar

Level 1

Thanks Niall, works like a charm

It is a damn cute photo