how to make previous and next buttons

Discussion in 'HTML & Website Design' started by Be Different, Oct 9, 2009.

  1. #1
    Hi,
    I am making a site in which I want to show a photo gallery. (which is all made manually means I did not use any slideshow (flash , xml) codes. But now I am facing a problem its When I click to the thumbnails I redirect to the bigger image of that particular image But I don't know how to make the buttons for next images and previous images (I mean working or code)
    Any help would be highly appreciated.
    Regards
     
    Be Different, Oct 9, 2009 IP
  2. mydreams.success@gmail.co

    mydreams.success@gmail.co Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hey if you have some time to spent on this then you can do one thing that just make a separate page for each image and post next and previous link on each page. Previous link will redirect to previous page and next link will redirect to next page
     
  3. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    437
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Dan Schulz, Oct 9, 2009 IP
  4. Be Different

    Be Different Active Member

    Messages:
    141
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #4
    thanks a lot friends .. It seems the script (you have mentioned) will solve my problem , by linking each and every page will take some time so let me try the script. anyways thanks for your help :)
     
    Be Different, Oct 11, 2009 IP
  5. forextrendalerts

    forextrendalerts Guest

    Messages:
    132
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    index = 0;
    quotes = [PUT YOUR QUOTES IN HERE];
    quotesLength = quotes.length;
    quoteDiv = document.getElementById("quotebox");
    fun getFirst()
    {
    quoteDiv = document.getElementById("quotebox");
    quoteDiv.innerHTML = "<p>" + quotes[index] + "</p>";
    document.getElementById("prev").disab… = "disabled";
    }
    fun getNext()
    {
    quoteDiv = document.getElementById("quotebox");
    nextButton = document.getElementById("next");
    document.getElementById("prev").disab… = "";
    index += 1;
    if(index + 1 == quotesLength)
    {
    nextButton.disabled = "disabled";
    }
    else
    {
    nextButton.disabled = "";
    }
    quote = quotes[index];
    quoteDiv.innerHTML = "<p>" + quote + "</p>";
    }
    fun getPrevious()
    {
    quoteDiv = document.getElementById("quotebox");
    prevButton = document.getElementById("prev");
    index -= 1;
    if(index - 1 == -1)
    {
    prevButton.disabled = "disabled";
    }
    else
    {
    prevButton.disabled = "";
    }
    document.getElementById("next").disab… = "";
    quote = quotes[index];
    quoteDiv.innerHTML = "<p>" + quote + "</p>";
    }

    On the body tage, put onload="getFirst();"

    In the body part, where you want the quote to show, make a div with the id="quotebox", and then make two buttons, one with an id="prev" and one with an id="next", and for each button, onclick="getPrevious();" or onclick="getNext()";
     
    forextrendalerts, Oct 12, 2009 IP
  6. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    437
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Actually, rather than put JavaScript in the body tag, just write a function that gets called when the page loads that will handle the onload event handler. That way you can call multiple onloads. :)

    
    window.onload = function() {
    	getFirst();
    	// other functions that use onload="" go here
    }
    
    Code (markup):
    I also recommend using document.getElementByID(); to target those IDs that need the previous and next calls rather than inlining them within the HTML code.
     
    Dan Schulz, Oct 12, 2009 IP