www.webdeveloper.com
Results 1 to 2 of 2

Thread: Display images based in a form field value

  1. #1
    Join Date
    Nov 2011
    Posts
    31

    Display images based in a form field value

    Hi,

    I have a form with fields: asset_name, asset_type and asset_serialNumber.

    How can I dispay one image that is in the "/assetserianumber" folder using javascript based on the content of asset_serialNumber form field?

    The image will be named "assetserianumber".jpg

    Thanks!

    RESA

  2. #2
    Join Date
    May 2010
    Posts
    213
    Code:
    function displayImage( serialNumber ) {
    
       document.getElementById("image").src = serialNumber + ".jpg";
    
    }
    Assuming "image" is the ID of the image element. And now you can invoke this function after the value of the field changed or whatever...

    Code:
    <input type="text" name="asset_serialNumber" onkeyup="displayImage( this.value );"/>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles