Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6636389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:10:47+00:00 2026-05-25T23:10:47+00:00

I have created an rotating image banner module for an in house CMS. I

  • 0

I have created an rotating image banner module for an in house CMS. I did not write all the jquery for this and that’s why I’m a little confused.

Basically the problem is the first image displayed in the banner after a page reload does not fade out like the rest of the images do. I understand that this probably because it is the default image loaded and is not part of the loop that’s causing the image banner to rotate. The banner can be seen here: http://www.easyspacedesign.com/craig/dentalwise/

Notice how the first image after a reload sort just jumps to the next image but then all he images afterwards smoothly fade in and out.

How do I grab that first image after a reload and make it fadeout like rest?

here is the code:

<script type="text/javascript">
<!--

var doLooop = true;

$(document).ready(function(){
setInterval("loop()",5000);
});

function loop(){
if(!doLooop){ return; }
var $total = parseInt($("input[name=total_slides]").val());
var $id = parseInt($("a._active").attr("rel"));
var $new = $id+1;
if($new>$total){$new=1;}
changeSlide($new);
}

function changeSlide($id){
// Prepare selectors
var $total = $("input[name=total_slides]").val();
var $txtSlt = "#_slideText_"+$id;
var $imgSlt = "#_slideImg_"+$id;
var $active = $("a._active").attr("id");
var $new_img_href = "#animation_selectors a:nth-child("+$id+") img";
var $new_active = "#animation_selectors a:nth-child("+$id+")";
// Hide active images and text    
$(".slideImg").css("display","none");
$(".slideTxt").css("display","none");
// Display selected images and text 
$($txtSlt).fadeIn(1200);
$($imgSlt).fadeIn(1200);
$($txtSlt).delay(2500).fadeOut(1200);
$($imgSlt).delay(2500).fadeOut(1200);   
// Update active anchor image
$("a._active img").attr("src","<?php echo ROOT; ?>Images/StyleImages/off.png");
$("a._active").removeClass("_active");
$($new_img_href).attr("src","<?php echo ROOT; ?>Images/StyleImages/on.png");
$($new_active).addClass("_active");
}

$(function(){
$("#animation_selectors a").click(function(e){
          e.preventDefault();                                  
    var $id = $(this).attr("rel");
    doLooop = false;
    changeSlide($id);
});
});

-->
 </script>
<div id="animation">

<div id="animation_slides">
    <?php
    $img_sql = "SELECT strImageUrl FROM tbl_mod_Animation ORDER BY intAnimationID";
    if($img = $db->get_results($img_sql)){ $i=1;
        foreach($img as $img){ 
            if($i!=1){ $display = " style=\"display:none;\""; } else { $display  = ""; }
            echo "<div id=\"_slideImg_$i\" class=\"slideImg\" $display><img   src=\"".ROOT."Images/Uploads/Slides/".$img->strImageUrl."\" alt=\"\"  /></div>"; 
            $i++;
        }
    }
    ?>
</div>
<div id="animation_text">
    <?php
    $text_sql = "SELECT strText FROM tbl_mod_Animation ORDER BY intAnimationID";
    if($text = $db->get_results($text_sql)){ $i=1;
        foreach($text as $text){ 
        if($i!=1){ $display = " style=\"display:none;\""; } else { $display = ""; }
        echo "<div id=\"_slideText_$i\" class=\"slideTxt\" $display>".$text->strText."</div>"; 
        $i++;
        }
    }

    ?>
</div>

<div id="animation_selectors">
    <?php
    for($x=1;$x<$i;$x++){
        if($x==1){ 
            ?><a  id="slide_opt<?php echo $x; ?>" href="#" rel="<?php echo $x; ?>" class="_active"><img class="slideOpt" src="<?php echo ROOT; ?>Images/StyleImages/on.png" alt="" /></a><?php 
            } else {
            ?><a  id="slide_opt<?php echo $x; ?>" href="#" rel="<?php echo $x; ?>"><img class="slideOpt" src="<?php echo ROOT; ?>Images/StyleImages/off.png" alt="" /></a><?php 
            }
        }
    echo "<input type=\"hidden\" name=\"total_slides\" value=\"".($i-1)."\" />";

    ?>
</div>

</div><!--end of animation-->
<?php

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:10:48+00:00Added an answer on May 25, 2026 at 11:10 pm

    changeSlide() sets up each slide to fade in and then fade out in 2.5 seconds. loop() calls changeSlide() every 5 seconds and passes the id of the next slide to be shown. The problem is that the first slide isn’t set up the same way on page reload. It’s probably just statically written on the page with the _active class.

    You’d be better off, instead of setting a delay to fade each slide out after 2.5 seconds, to pass in both the previous and next slide to the changeSlide function and then fade out the previous and fade in the next.

    function loop() {
        ... 
        changeSlide($id, $new);
    }
    

    and then in changeSlide:

    function changeSlide($prev, $next) { 
         ...
         var $prevTxtSlt = "#_slideText_" + $prev;
         var $prevImgSlt = "#_slideImg_" + $prev;
         var $nextTxtSlt = "#_slideText_" + $prev;
         var $nextImgSlt = "#_slideImg_" + $prev;
         ...
         $($prevTxtSlt).fadeOut(1200);
         $($prevImgSlt).fadeOut(1200);
         $($nextTxtSlt).fadeIn(1200);
         $($nextImgSlt).fadeIn(1200);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created some JQuery that will expand a div 'popup' on hover and
I have created a rotating banner script for a new site I'm developing View
I need to solve a problem by rotating an image, but I have this
with some help I have created a rotating slider using jquery and CSS3, and
I have created an android application that calls (using kSOAP library) a SOAP based
I have created a function that shows/hides different messages according to a combination of
I have created a dialog and got a problem that only part of the
I have created a rotating CUBE with the help of OPENGL in Android now
I created a simple rotating banner for a website I created http://sandbox.worldwatchlist.us . Everything
I have an ImageManipulator class that performs some cropping, resizing and rotating of camera

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.