dimanche 31 janvier 2021

Unable to change variable by function

I can't figure out why my function getID() isn't changing the galleryID variable. Any help appreciated!

var img;
var gallery = {0: "CIBf-QSFMZD", 1: "CFfihZ0BxQo", 2: "CDUNuwvgB7N", 3: "CByDTh8gUWa", 4: "CB3i7NoA-IK", 5: "CKSEJG9rlJn", 6: "CEHrD8yAFXn", 7: "CIY6OZ-FGJB", 8: "B-12Va2DQ96", 9: "CB3e-QHAx5e", 10: "CI29bFllEBm", 11: "B1enhruHg9i"};
var galleryID;
function on(ima) {
  img = ima.id;
  document.getElementById("instagram-embed").src = "https://www.instagram.com/p/" + img + "/embed?utm_source=ig_embedembed/captioned/";
  document.getElementById("overlay").style.display = "block";
  document.getElementbyId("container").style.backgroundColor = "black";
  document.getElementById("container").style.zIndex = "2";
  getID();
}

Everything seems to work fine aside from the function below

function getID() {
var i = 0;
while(!(img == gallery[i])){
i++;
}
galleryID = i;
}

The value of galleryID just won't change from undefined. I've checked the equality comparison statement separately and it seems to be working ok, giving the right true and false outputs.

Thanks for any help!




Aucun commentaire:

Enregistrer un commentaire