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 8332817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:49:49+00:00 2026-06-09T02:49:49+00:00

I created a slider But I am going some where wrong in my logic.

  • 0

I created a slider But I am going some where wrong in my logic. I am able to show all the images, but not in an order. So initially image1 after that image2.. the sequence is going wrong in my logic.
And the image should load as we enter into the browser, it took some time to load.

here is the live demo link:

http://codebins.com/bin/4ldqp9c/2#

HTML

<div id="panel">
  <div id="title">
  </div>
  <img id="imageSlide" alt="" src="" width="250px"/>
  <div id="desc">
  </div>
</div>

JS

$(function() {
    //Local XML Data
    var slideXML = "<rss version='2.0'><channel>";
    slideXML += "<title>IMAGES</title>";
    slideXML += "<images>";
    slideXML += "<image>";
    slideXML += "<title>Image 1</title>";
    slideXML += "<url>http://www.academy-florists.com/images/shop/thumbnails%5CValentines_Day_flowers.jpg</url>";
    slideXML += "<desc>Description For Image 1</desc>";
    slideXML += "</image>";
    slideXML += "<image>";
    slideXML += "<title>Image 2</title>";
    slideXML += "<url>http://www.everythingbuttheprincess.com/assets/images/babies-in-bloom-fuchsia-flower_thumbnail.jpg</url>";
    slideXML += "<desc>Description For Image 2</desc>";
    slideXML += "</image>";
    slideXML += "<image>";
    slideXML += "<title>Image 3</title>";
    slideXML += "<url>http://www.behok.ru/i/a/cat/gerbera.jpg</url>";
    slideXML += "<desc>Description For Image 3</desc>";
    slideXML += "</image>";
    slideXML += "<image>";
    slideXML += "<title>Image 4</title>";
    slideXML += "<url>http://www.thebutterflygrove.com/images/thumbnails/0/200/200/thumbnail_flower-decor-makpk.jpg</url>";
    slideXML += "<desc>Description For Image 4</desc>";
    slideXML += "</image>";
    slideXML += "<image>";
    slideXML += "<title>Image 5</title>";
    slideXML += "<url>http://www.thebutterflygrove.com/images/thumbnails/0/200/200/thumbnail_flower-decor-makpk.jpg</url>";
    slideXML += "<desc>Description For Image 5</desc>";
    slideXML += "</image>";
    slideXML += "<image>";
    slideXML += "<title>Image 6</title>";
    slideXML += "<url>http://gameinfestedent.com/gallery_photo/medium_image/image1322820610_MainPurpleOrchids3_1a.jpg</url>";
    slideXML += "<desc>Description For Image 6</desc>";
    slideXML += "</image>";
    slideXML += "</images>";
    slideXML += "</channel></rss>";

    //Parse XML content
    var xmlDoc = $.parseXML(slideXML);
    var $xmldata = $(xmlDoc);

    //Find Total No of Image
    var maximages = ($xmldata.find("images").find("image").length);


    $(function() {
        //FadeIn/FadeOut Image on Set Time Interval on Slide
        setInterval(Slider, 2500);
    });

    var prevIndex = 0;

    function Slider() {
        $('#imageSlide').fadeOut("slow", function() {
            var shuffleIndex = Math.round((Math.random() * (maximages - 1)));
            if (prevIndex == shuffleIndex) {
                if (prevIndex >= (maximages - 1)) {
                    shuffleIndex--;
                } else {
                    shuffleIndex++;
                }
            }
            prevIndex = shuffleIndex;
            $("#panel").fadeIn("slow").css('background', '#000');

            var title = $xmldata.find("images").find("image:eq(" + shuffleIndex + ")").find("title").text();
            $("#title").text(title).fadeIn("slow");

            var imgurl = $xmldata.find("images").find("image:eq(" + shuffleIndex + ")").find("url").text();
            $(this).attr('src', imgurl).fadeIn("slow");

            var desc = $xmldata.find("images").find("image:eq(" + shuffleIndex + ")").find("desc").text();
            $("#desc").text(desc).fadeIn("slow");

        });
    }

});
  • 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-06-09T02:49:50+00:00Added an answer on June 9, 2026 at 2:49 am

    this http://codebins.com/bin/4ldqp9c/23 ?

          if  ( prevIndex < maximages ){
           shuffleIndex = prevIndex;
           prevIndex++; 
          }
          else {
            prevIndex=0;
            shuffleIndex=prevIndex;
            prevIndex++;
          }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created my jquery price slider but I am not sure how to
I've created custom toggle slide animation. Its working fine as expected but its not
I have created a slideshow using jquery easyslider. But its not happening. I am
Hi I have created a slider in java in linux platform. But the slider
I created a custom event called slides.swap but I want to prevent the event
I have created jquery image slider and it is working good. However i have
I recently started using JQuery and created a little slider to display logos of
I have a page which contains a jQuery-UI horizontal slider, created using a little
I'm working on pizzli.com/darrenwp. I've created a featured content slider using Jquery/Jquery UI and
I have created a volume controller for iTunes but I would like this app

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.