SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Change image

    Hi sitepointers,

    i have a current script that takes a value on click of a hyperlink and uses it to change an image.

    PHP Code:
    <script language='javascript'>
        function 
    changeImage(URL) {
        var 
    image document.getElementById('change');
        
    image.src URL;
        }

    </script> 
    PHP Code:
    onclick='changeImage("/image/image.jpg"); return false;

    which changes :

    <img id='
    change' src='/image/image.jpg'> 
    can somone change the code so that i can have an input box, which when the contents of the input box changes (i.e put an image url in there) then the image changes automatically?

    any help would be great...im new to js and need help..

    Thank You

    Rodent

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Code html:
    <input type="text" onchange="changeImage(this.value)" />
    Saul

  3. #3
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you SOOO much

    Works great!


Bookmarks

Posting Permissions

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