I have a requirement where i need to set a default image if the image is not uploaded by user. I am trying to set the image using javascript. My image is located in images folder of my project in eclipse.
my html code is:
<tr>
<td align="right">Upload Image :</td>
<td>
<input type="file" id="imageNonSaml" name="imageNonSaml" value=""/>
</td>
</tr>
my javascript is :
function testSSO(){
var image=document.getElementById("imageNonSaml").value;
if(image==null || image==''){
alert("inside if");
document.getElementById('imageNonSaml').setAttribute('name',"/assets/img/generic.png");
}
}