el_dorito
03-04-2005, 03:21 PM
Hi,
The goal:
A user selects an image fil on his pc true an input file field.
A javascript function display's a preview on it next to the file field (without actually oploading the file)
The RPoblem:
I used a JS before but it's not Firefox compatibel so I'm trying to fix it
old JS:
<script language="Javascript" type="text/javascript">
function setImage1(string){
document.getElementById('previewfoto1').src = 'File:\/\/' + string;
}
</script>
What I got now but doesnt work
<script type="text/javascript" language="javascript">
function setImage(string)
{
var image =document.getElementById('previewfoto1').
image.Setatrribute('src','File:\/\/'+ string);
//also tried this
image.src='File:\/\/'+ string';
}
</script>
the script is called like this:
<input type="file" name="foto'.$i.'" id="foto'.$i.'"onchange="setImage(this.value);"></span>
<span class="right"><img width="50" id="previewfoto1" src="../images/site/tableft.gif" alt="preview" ></span>';
Regards
Geert
The goal:
A user selects an image fil on his pc true an input file field.
A javascript function display's a preview on it next to the file field (without actually oploading the file)
The RPoblem:
I used a JS before but it's not Firefox compatibel so I'm trying to fix it
old JS:
<script language="Javascript" type="text/javascript">
function setImage1(string){
document.getElementById('previewfoto1').src = 'File:\/\/' + string;
}
</script>
What I got now but doesnt work
<script type="text/javascript" language="javascript">
function setImage(string)
{
var image =document.getElementById('previewfoto1').
image.Setatrribute('src','File:\/\/'+ string);
//also tried this
image.src='File:\/\/'+ string';
}
</script>
the script is called like this:
<input type="file" name="foto'.$i.'" id="foto'.$i.'"onchange="setImage(this.value);"></span>
<span class="right"><img width="50" id="previewfoto1" src="../images/site/tableft.gif" alt="preview" ></span>';
Regards
Geert