problem with setting image source dynamically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shivendravikramsingh
    New Member
    • Jun 2007
    • 19

    #1

    problem with setting image source dynamically

    hi friends,i have a problem i m using this code for displaying image.this code is working fine when we run this code in internet Explorer but when the same page with this code i can in mozilla or firefox,the image is not display.i m very much frusteted,pls help me friend,this is the code i m using:
    the javascript function:[code=javascript]
    function loadIndividual( form) {
    var gifName = form.vendorimag eupload.value;
    document.vendor image.src = gifName;

    }[/code]

    and i call this function in this button:[code=html]
    <input type="file" name="vendorima geupload" id="vendorimage upload" onChange="loadI ndividual(this. form)">[/code]

    the image shold display in this :
    [code=html]
    <img name="vendorima ge" width="147" height="135" id="vendorimage ">[/code]
    Last edited by pbmods; Sep 16 '07, 12:08 PM. Reason: Added CODE tags.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    hi ...

    for refering the image-node you should use the standards-compliant dom method:

    [CODE=javascript]var img_node = document.getEle mentById('img_i d');
    [/CODE]
    and then set the new img-src:

    [CODE=javascript]img_node.src = 'new_im_src.jpg ';[/CODE]
    kind regards

    Comment

    Working...