However, I did realize the core of the issue was that I shouldn't
have been calling the onclick within the function that was creating
the thumbnails.
So which I solved the issue of why the imageIndex values were getting
messed up, it left me with another problem:
If I'm creating those thumbnail images on the fly, into an array, how
do I know which thumbnail was clicked? I have built the function to
change the main image, and it works well, but I have to explicitly
tell it what to do for thumb0, thumb1, etc. I'm trying to write a
function that knows which index was chosen. I'm probably overlooking
something very simple, but I'm stuck!
thanksbeth
On Nov 10, 5:52 pm, Nathan Mynarcik <nat...@mynarcik.com> wrote:
> try this:
>
> for (i=0; i<imageArray.length; i++) {
> thumbnailArray[i] = document.createElement("img");
> dynamicThumbs.appendChild(**thumbnailArray[i]);
> thumbnailArray[i].**setAttribute("src",imageArray[**i]);
> thumbnailArray[i].**setAttribute("width",100);
> thumbnailArray[i].onclick = function(){
> currentSlide.setAttribute("**src", imageArray[i]);
> currentSlide.setAttribute("**href", linkArray[i]);
> if (i < imageArray.length-1){ //length gives you total; yet
> arrays are zero based
> imageIndex++;}
> else {
> imageIndex = 0;
> };
> };
>
> }
>
> Nathan Mynarcik
> nat...@mynarcik.comwww.mynarcik.com
>
>
>
>
>
>
>
> On Thu, Nov 10, 2011 at 11:32 AM, beth <eliz...@gmail.com> wrote:
> > for (i=0; i<imageArray.length; i++) {
> > thumbnailArray[i] = document.createElement("img");
> > dynamicThumbs.appendChild(**thumbnailArray[i]);
> > thumbnailArray[i].**setAttribute("src",imageArray[**i]);
> > thumbnailArray[i].**setAttribute("width",100);
> > thumbnailArray[i].onclick = function(){
> > currentSlide.setAttribute("**src", imageArray[i]);
> > currentSlide.setAttribute("**href", linkArray[i]);
> > if (i < imageArray.length){
> > imageIndex++;}
> > else {
> > imageIndex = 0;
> > };
> > };
> > }
--
You received this message because you are subscribed to the Google Groups "JavaScript Forum" group.
To post to this group, send email to javascript-information@googlegroups.com.
To unsubscribe from this group, send email to javascript-information+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/javascript-information?hl=en.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.