Can anyone help me with this (Image handling with JS)

Discussion in 'JavaScript' started by hansab, Nov 1, 2008.

  1. #1
    i can do it in aSP but i want to do it in JS.

    So i will tell you what i want to do, and if any one can give me the code or guide me to do this.

    What i want is..

    On Index.html I have a image. And there are two buttons there. One is for next and one is for prev.

    When a user click next button the page refresh with the variable (index.html?something) and then the next image from the folder is displayed.

    All the images in the folder have names like this

    1.jpg
    2.jpg
    3.jpg
    and so on...

    so now please tell me how do i do. I am very bad in explaining when it comes to writing..... so please dont mind and just help me. I hope all the js ppl will understand what i actually want.

    Thank you.
     
    hansab, Nov 1, 2008 IP
  2. BrandonGregory

    BrandonGregory Peon

    Messages:
    28
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    // Grab the image from the URL
    var url = window.location;
    var imgVar = url.split("?");
    var imgName = imgVar[1];

    // Now, set the src of the object to the image
    document.getElementById("yourImage").src = imgName;



    Does that answer your question?
     
    BrandonGregory, Nov 3, 2008 IP
  3. hansab

    hansab Active Member

    Messages:
    162
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #3
    yes, not completely but now i have an idea... thanks alot. i will handle it now.
     
    hansab, Nov 3, 2008 IP