If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

passing var to image switch

I am modifying an existing PHP image gallery to add dynamic UI.

I have a nice (jquery) thumbnail slider which builds dynamically and I can add (some kind of) javascript call to each thumbnail - perhaps onclick= to set up the variable for the main image to be displayed below.

This is the bit I get lost - how to pass that variable to this bit of jquery which displays the main image?

although it is loosening, there is a historical requirement against having IDs that start with numbers. you could set another attribute, however, lets say ind, so your thumbnails would have ind="0", ind="1" in their img tag, according to which larger image they related to.

then, say your thumbs had a class of "thumbs", I think your function would look like this:

untested, but it will probably work. It would probably make more sense to have the filenames of the thumbs and larger pics related (like chococatsmall.gif and chococatbig.gif, comicsmall.gif and comicbig.gif) so that you could do the swicth independent of array position, but that's up to you...

@xelawho
Yes, thumbs are currently tn_NAME.jpg - against NAME.jpg
Would it be a case of setting ID=NAME.jpg
and then setting:
var image = images[$(this).attr('ID')];
edit:.... thinking - could this just be: var image = $(this).attr('ID');

I will try this.

@DanInMa - I will also try using the bg tag

PS - the js I have is from a background changer I found. Can it be simplified?