Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Badly need helps from experts


    hey all,
    im interested in learning to make slide show using javascript..i read some article and got some ideas somehow when i tried to create by my own it give me problem...i got some example from Internet and tried it...this is the code that i got and i edited it to what i want:
    For example here:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <script language="javascript">
    var image1=new Image();
    var image2=new Image();
    var image3=new Image();
    image1.src="index.jpg";
    image2.src="index1.jpg";
    image3.src="index2.jpg";
    </script>
    </head>
    <body>
    <img src="./index.jpg" name="slide">
    <script>
    //variable that will increment through the images
    var incre=1;
    function slidepics(){
    document.images.slide.src=eval("image"+incre+".src ");
    if (step<3)
    {step++;}
    else
    {step=1;}
    //after 1s the pics will be changed
    setTimeout("slidepics()",1000);
    }
    slidepics();
    </script>
    </body>
    </html>

    So any ideas...please help cause i tried it since yesterday and dont get why it didnt do as i wished...huhu...thanks in advanced

  2. #2
    I modified your code slightly (to make it easier for me to read) and changed the way the Javascript gets called, try this:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <script type="text/javascript">
    
    var image1 = 'index.jpg'
    var image2 = 'index1.jpg'
    var image3 = 'index2.jpg'
    
    var step = 1;
    
    slideshow();//call the function.
    
    function slideshow() {
      var myid = 'slide';
      var image = image = eval('image'+step);
      if(document.getElementById(myid)){
        document.getElementById(myid).src = image;
      }
    
      if(step<3){
        step++;//increment counter
      } else {
        step=1;
      }
      setTimeout( slideshow, 1000 );
    }
    
    </script>
    </head>
    <body>
    <img id='slide' src='index.jpg'>
    </body>
    </html>

  3. #3
    thanks for ur code it works really well...

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •