Can not get function to fire

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lawrence

    Can not get function to fire

    I'm trying to modify a script to work on my site, but I can figure out
    how to call it. I've two lines of PHP printing out this bit of a form:

    echo "<input type=\"file\" name=\"uploaded File\">";
    echo "<input type=\"hidden\" name=\"uploadTy pe\" value=\"image\"
    onchange=\"DoPr eview();\">";


    This function is listed above the form. is onchange() the correct
    trigger?





    <script language="javas cript">
    function DoPreview()
    {
    var filename = document.forms[0].inputId1.value ;
    var Img = new Image();
    if (navigator.appN ame == "Netscape")
    {
    alert("Previews do not work in Netscape.");
    }
    else
    {
    Img.src = filename;
    ppImg = Img.src;
    alert("You're loading image" + ppImg);
    document.images[0].src = Img.src;
    }
    }
    </script>
  • Matt Kruse

    #2
    Re: Can not get function to fire

    lawrence wrote:[color=blue]
    > echo "<input type=\"hidden\" name=\"uploadTy pe\" value=\"image\"
    > onchange=\"DoPr eview();\">";[/color]

    Hidden inputs do not have an onChange event, since the user can't change the
    value manually.
    In whatever code triggers the population of this form field, also call the
    DoPreview() function.

    --
    Matt Kruse
    Javascript Toolbox: http://www.JavascriptToolbox.com/


    Comment

    Working...