how to make this javascript repeat

Discussion in 'JavaScript' started by kluki2008, May 24, 2010.

  1. #1
    hi
    I am new to javascript
    currently I have a website with a big banner at the header of website.
    This big banner is consists with three pictures.
    each pictures will display once according to their order, and after first cycle the banner will stop at the first one which in javascript code is set to be "0"
    please see details below

    My problem is that I want to make banner to repeat as much time as it could, but not only once.
    How can I do that,
    I try to use "for" and "while" but couldn't work
    may be I am just too new to fixed this simple problem

    my website is choiceware.com.au
    and the banner with problem is the big banner in the header position.

    thanks in advance.
     
    Last edited: May 24, 2010
    kluki2008, May 24, 2010 IP
  2. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't know about jQuery but in javascript it's something like this

    setTimeout('slider_intro()', 3000);
     
    Imozeb, May 24, 2010 IP
  3. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #3
    
    jQuery(window).bind("load", function () {
        jQuery("div#mygalone").slideView();
    
        var slider_links = jQuery('.stripTransmitter li a');
        var slider_links_index = 0;
    
        function slider_intro() {
            slider_links.eq(slider_links_index).trigger('click');
            slider_links_index++;
            if (slider_links_index <= slider_links.size()) {
                setTimeout(function () {
                    slider_intro()
                }, 3000); //select change time
            }
            else if (slider_links_index > slider_links.size()) {
                slider_links.eq(0).trigger('click');
                // restart after 3 seconds
                setTimeout(function() {
                    slider_links_index = 0;
                    slider_intro();
                }, 3000);
            }
    
    
        }
                    
        slider_intro();
    
    
    });
    
    Code (javascript):
    perhaps something like this. a self-calling function is not how i'd code this though, probably i'd use something like var timer = setInterval(function() { do something to an image }, 3000); instead.
     
    dimitar christoff, May 25, 2010 IP