Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jun 2004
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I make an automatic slideshow of images wtihout using the name attribute?

    How do I make an automatic slideshow of images wtihout using the name attribute for the img tag?
    Last edited by ampulator00; 06-30-2004 at 07:43 AM.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts

    If I understood you correctly...

    You can use the index position of the image in the images collection if you know it. The problem with that is if you insert an image before the slideshow image, the code will not work anymore. Using the name attribute is better.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New Coder
    Join Date
    Jun 2004
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, but the name attribute for the img tag is unfortunately not XHTML 1.1 Strict. BTW, when you say image position, you mean z-index, right? How would I use it?
    Last edited by ampulator00; 06-30-2004 at 07:52 AM.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    when you say image position, you mean z-index, right? How would I use it?
    No.

    document.images[0].src = theSlide;

    That means the img tag is the first image in the document. index is zero-based.

    but the name attribute for the img tag is unfortunately not XHTML 1.1 Strict.
    Then use id and then document.getElementById instead of document.images

    document.getElementById('theId').src = theSlide;
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    New Coder
    Join Date
    Jun 2004
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks! the ID thing worked! BTW, is it possible to use an class instead of an ID?
    Last edited by ampulator00; 06-30-2004 at 08:07 AM.

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You can't reference the image using getElementById without an id attribute.

    If you're concerned with applying CSS to the image, then you can use this:

    img#theId {
    border:none;
    }

    but if you want to reuse it in other img tags, you can use class names.

    img.theClass {
    border:none;
    }
    ...
    <img id="theId" class="theClass" src="first.jpg" alt="" />


    Regarding js refs, see the sticky in this forum.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #7
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Images array:


    <script>
    <!--

    myImgs = new Array()
    myImgs[0]="image1.gif";
    myImgs[1]="image2.gif";
    myImgs[2]="image3.gif";
    myImgs[3]="image4.gif";
    myImgs[4]="image5.gif";
    myImgs[5]="image6.gif";
    imgNum=0;
    imgCt=myImgs.length;
    function showImgs(){
    if(document.images){
    if(document.images[0].complete){
    imgNum++;
    if(imgNum==imgCt){
    imgNum=0;
    }
    }
    }
    document.images[0].src=myImgs[imgNum];
    }
    //-->
    </script>

    <body onload="javascript:setInterval('showImgs()',1000);">

    <img name="slideshow" src="Image1.gif" width="150" height="150" border=0>


    -james
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "

  • #8
    New Coder
    Join Date
    Jun 2004
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, Too!


  •  

    Posting Permissions

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