jake2891 Posted April 30, 2010 Share Posted April 30, 2010 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>"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.