Hello,
I’m trying to compare an array to a variable and see if it has the same value then output the second part of the array:
[CODE]
<script language=”javascript”>
var photoCaptionID0 = “13006”;
var photoCaptionID1 = “24018”;
var photoCaptionID2 = “13002”;
var photoCaptionID3 = “24065”;
var photoCaptionID4 = “24021”;
var photoCaptionID5 = “24005”;
var captionID = new Array();
captionID[0] = “13006, Item 1”;
captionID[1] = “24018, Item 2”;
captionID[2] = “13002, Item 3”;
captionID[3] = “24065, Item 4”;
captionID[4] = “24021, Item 5”;
captionID[5] = “24005, Item 6”;
for(var i = 0; i < captionID.length; i++){
if (captionID[i][0] == photoCaptionID0){
break;
document.getElementById(“photoCaptionID0”).innerHTML = captionID[i][1];
}
}
</script>
So using this example. If any of the first section in the array captionID (24001, 13001, etc) has the same value as photoCaptionID0, then print the second part of captionID (Item 1, Item 2, etc).
Thanks much!
–thesprucegoose