How to load pictures instantly?

Discussion in 'PHP' started by jpmad4it, Mar 19, 2007.

  1. #1
    hey everyone,

    I want to find out if its possible to load an image dynamically on the click of a button, within the same webpage. For example I want to have a thumbnail which has a link to a larger image, which will be loaded without having to open up a pop-up or separate page. I'd have 4 or 5 thumbnails at the top of the page, and then a larger area below that where the larger image is loaded on the click of the thumbnail. Is this possible? How could it be done? I know this is probably a relatively easy question, so sorry for being a newbie LOL ;D

    regards Jp
     
    jpmad4it, Mar 19, 2007 IP
  2. TomK32

    TomK32 Peon

    Messages:
    113
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Javascript is what you need. You could try a library like JQuery or Prototype but I guess these few lines should do it:
    <script type="text/javascript">
    function changeImg(img, el) {
    	if (el == undefined)
    		el = "fullsize";
    	i = document.getElementById(el);
    	i.src = img;
    }
    </script>
    
    <a href="javascript:changeImg('iamge1.png');">image1</a>
    
    <img id="fullsize" />
    
    HTML:
     
    TomK32, Mar 19, 2007 IP
  3. jpmad4it

    jpmad4it Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i just realised JS is what i need. Sorry for posting in the wrong palce !!
     
    jpmad4it, Mar 19, 2007 IP