I have a small piece of noddy code, when clicking an image the user can change the source. This is the function I use
function doStuff(objId){
newVal = prompt("new Value")
if(newVal==""){
newVal = "blank"
}
document.getElementById(objId).src=newVal+".png"
}
Is there a way to check before setting the src if that is a valid filename at the same point as when I check if the user has not specified anything? I'd like to be able to protect the page so if the user types "banana" and there is no banana.png available that I just change it to the blank.png file.
I've found various methods for doing it on error but wasn't sure how to do it in this instance as none of those seem to trigger if the page is being updated dynamically.
Thanks!
srcproperty.