Jump to content

help needed with scriptaculous image slide show


jake2891

Recommended Posts

hey guys, im using a simple slide show script that i came across on the web. however it was intended for one slid show par page. I am using 4 in the same page and have modified it slightly but for some reason i had to set timeouts when calling the function for the images to not disappear off the screen. and also even with a timeout fix after a while some images keep dissappearing? any suggestions or help thanks?

 

javascript code below and php code bleow that.

 

var delay = 2000;
var start_frame = 0;
var lis;


function slideshowinit(element) {
  
lis = $(element).getElementsByTagName('li');

for( i=0; i < lis.length; i++){
	if(i!=0){
		lis[i].style.display = 'none';
	}
}
end_frame = lis.length -1;

start_slideshow(start_frame, end_frame, delay, lis);


}



function start_slideshow(start_frame, end_frame, delay, lis) {
setTimeout(fadeInOut(start_frame,start_frame,end_frame, delay, lis), delay);
}


function fadeInOut(frame, start_frame, end_frame, delay, lis) {
return (function() {
	//lis = $(element).getElementsByTagName('li');
	Effect.Fade(lis[frame]);
	if (frame == end_frame) { frame = start_frame; } else { frame++; }
	lisAppear = lis[frame];
	setTimeout("Effect.Appear(lisAppear);", 0);
	setTimeout(fadeInOut(frame, start_frame, end_frame, delay,lis), delay + 1850);
})

}

//php 
              // i have left out a bit of code where it loops to increment the $s etc... there is nothing wrong with the php i dont think. its something to do with the javascript.
               $s = 0;
                $Q = $db->queryAll("select * from foo_table");
                $CONTENT .= "<div id=\"slide-show$s\" >";
                $CONTENT .= "<ul id=\"slide-images$s\" class=\"slide-images\">";
                foreach($Q as $q){
                    
                    $cover_src = $q['image_path'];
                    $cover_src = str_replace(UPLOAD_PATH,'',$cover_src);
                    
                    $CONTENT .= "<li>";
                                $CONTENT .= "<img src=\"$cover_src\" />"."\r\n";
                    $CONTENT .= "</li>";                
                    
                    
                    
                 
                }
                $CONTENT .= "</ul>";
                $CONTENT .= "</div>";

               //here i call the javascript slideshow

                $CONTENT .= "
                    <script type=\"text/javascript\" >
                        
                         setTimeout(\"slideshowinit('slide-images$s')\",$timeout);
                    </script>";  

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.