Re: Newbie Help with loops

Saturday, November 12, 2011

Thanks for that, that made sense but i didn't fix the problem.
 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.

Copyright © 2010 Web Design | Free Blogger Templates by Splashy Templates | Layout by Atomic Website Templates

Vida de bombeiro Recipes Informatica Humor Jokes Mensagens Curiosity Saude Video Games Animals Diario das Mensagens Eletronica Rei Jesus News Noticias da TV Artesanato Esportes Noticias Atuais Games Pets Career Religion Recreation Business Education Autos Academics Style Television Programming Motosport Humor News The Games Home Downs World News Internet Design Entertaimment Celebrities 1001 Games Doctor Pets Net Downs World Enter Jesus Mensagensr Android Rub Letras Dialogue cosmetics Genexus lasofia thebushrajr wingshock tripedes gorduravegetal dainfamia dejavu-transpersonal jsbenfica republicadasbadanas ruiherbon iranianforaryans eaystcheyl fotosdanadir Só Humor Curiosity Gifs Medical Female American Health Madeira Designer PPS Divertidas Estate Travel Estate Writing Computer Matilde Ocultos Matilde futebolcomnoticias girassol lettheworldturn topdigitalnet Bem amado enjohnny produceideas foodasticos cronicasdoimaginario downloadsdegraca compactandoletras newcuriosidades blogdoarmario arrozinhoii