I am using a remote .txt file to populate an array which populates a drop-down select. It looks like this.
var myAnimalList = new Array();
function Food(anAnimal, aSpecies, anImage ) {
this.Animal = anAnimal;
this.Species = aSpecies;
this.Image = anImage;
}
window.addEventListener("load", function(){
document.getElementById("selAnimal").addEventListener("change", animalChosen);
//big long string to parse
var myAnimalData = InsectData2.txt;
for (i = 0; i < AnimalDataLines.length; i++) {
myAnimalData[i] = new Animals(subdata[0], subdata[1], subdata[2], subdata[3]);
}
However, my problem is. In the .txt file the image names contain spaces and slashes for example:
"Brown Skipper/Paratrylone/melane"
The image name on the other hand looks like this:
"brown-skipperpartrlonemelane.jpg" . But the image name
How can I ensure that the .txt file name matches the image name before I add it to the array?