vin_akleh Posted September 8, 2010 Share Posted September 8, 2010 i have a banner that changes image every couple of seconds that retrieve the images from a static images like so: old code: var image1=new Image() image1.src="uploads/firstcar.gif" var image2=new Image() image2.src="uploads/secondcar.gif" var image3=new Image() image3.src="uploads/thirdcar.gif" var image4=new Image() image3.src="uploads/cat.gif" <div class="banner"> <p class="banner_image"> <a href="http://www.w3.org/"> <img src="banner/123.jpg" name="slide" width="290px"> <script> <!-- //variable that will increment through the images var step=1 function slideit(){ //if browser does not support the image object, exit. if (!document.images) return document.images.slide.src=eval("image"+step+".src") if (step<3) step++ else step=1 //call function "slideit()" every 2.5 seconds setTimeout("slideit()",2500) } slideit() //--> </script> </p> <p class="banner"> <a href="http://www.w3.org/">banner</a> </p> </div> know i want it to retrieve the images from database like so New modifications: <?php $count_im=1; $req=mysql_query("select * from banner"); while ($res=mysql_fetch_array($req)){ ?> var image<?php echo $count_im; ?> =new Image() image<?php echo $count_im; ?>.src="<?php echo $res["banner"]; ?>" <?php $count_im++; }?> but the problem is that it know freezes on the last image, it doesn't loop!! any ideas how to fix it Link to comment https://forums.phpfreaks.com/topic/212860-banner-freezing-after-some-modifications/ Share on other sites More sharing options...
Adam Posted September 10, 2010 Share Posted September 10, 2010 What does the JavaScript look like once rendered? Link to comment https://forums.phpfreaks.com/topic/212860-banner-freezing-after-some-modifications/#findComment-1109576 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.