Jump to content

aguy123

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by aguy123

  1. So I'm making a slide show for a specific page on my website. Here's the slideshow page I'm talking about: http://offsavingtheworld.com/extra
    I have the "previous" and "next" buttons worked out:

    <button class="w3-btn" onclick="plusDivs(-1)">❮ Prev</button>
    <button class="w3-btn" onclick="plusDivs(1)">Next ❯</button>

     

    What I'm trying to create are buttons that show the very first, very last, and a completely random image, if that's even possible. Is this even possible using the code I have here?:

    <p><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css"></p>

    <div class="w3-content" style="max-width:900px;position:relative">

    <img class="mySlides" src="IMG URL" style="width:100%"/><img class="mySlides" src="IMG URL" style="width:100%"/><img class="mySlides" src="IMG URL" style="width:100%"/><img class="mySlides" src="IMG URL" style="width:100%"/><div class="w3-center">
    <div class="w3-section">

    <button class="w3-btn" onclick="plusDivs(-1)">❮ Prev</button>

    <button class="w3-btn" onclick="plusDivs(1)">Next ❯</button>

    </div>

    </div>

    </div>

    </div>

    <script type=text/javascript>

     

    slideIndex = 1;
    showDivs(slideIndex);

    function plusDivs(n) {
    showDivs(slideIndex += n);
    }

    function showDivs(n) {

    var i;
    var x = document.getElementsByClassName("mySlides");
    if (n > x.length) {slideIndex = 1}
    if (n < 1) {slideIndex = x.length} ;
    for (i = 0; i < x.length; i++) {
    x.style.display = "none";
    }
    x[slideIndex-1].style.display = "block";
    }

    </script>

     

    Sorry if I posted this incorrectly. I'm new to this forum.

×
×
  • Create New...