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

click image to change same image via array of images

Avatar

Level 3

Hello,

I have an image in a form. I want to click the image and have it change to the next image in the array. WHen it gets to the end it would just loop around on the next click.

My code thoughts are below but it is not working - can anyone help?

var images = Array(   Image1.value.image.value   ,   Image2.value.image.value   ,    Image3.value.image.value   );

for (var i=0; i<images.length;i++ ){
    if(projectImageField.rawValue == images[2]) {
        projectImageField.rawValue = images[i];
    }
}

So the idea is I would click the image, it would check the array for the current position, add 1 and display the new image. If it checked and the position was at the end of the array it would start over again from 0.

Seems easy and yet I am unable to get it working. Thanks for your help.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Here is a sample. The main script is in the click event of the button. Please note that there is a global variable "vCurrent" in the form (File / Form Properties / Variables), which keeps track of the current image.

Please have a look at John Brinkman's recent blog on embedding images and linking images (http://blogs.adobe.com/formfeed/2009/11/linked_vs_embedded_template_im.html).

This example has nine embedded images, so the file size will be reflected by the size of the nine embedded images PLUS the size of the current image in the ImageField.

Good luck,

Niall

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

Here is a sample. The main script is in the click event of the button. Please note that there is a global variable "vCurrent" in the form (File / Form Properties / Variables), which keeps track of the current image.

Please have a look at John Brinkman's recent blog on embedding images and linking images (http://blogs.adobe.com/formfeed/2009/11/linked_vs_embedded_template_im.html).

This example has nine embedded images, so the file size will be reflected by the size of the nine embedded images PLUS the size of the current image in the ImageField.

Good luck,

Niall