Using only title is a common pitfall as different images can have the same title. Maybe add: id=getImageID; selectImage(id);