Can not get function to fire

L

lawrence

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=\"uploadedFile\">";
echo "<input type=\"hidden\" name=\"uploadType\" value=\"image\"
onchange=\"DoPreview();\">";


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





<script language="javascript">
function DoPreview()
{
var filename = document.forms[0].inputId1.value;
var Img = new Image();
if (navigator.appName == "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>
 
M

Matt Kruse

lawrence said:
echo "<input type=\"hidden\" name=\"uploadType\" value=\"image\"
onchange=\"DoPreview();\">";

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top