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!

10 thoughts on “Unable to change variable by function”

  1. 923936 812231 There are some fascinating points in time in this write-up but I dont know if I see all of them center to heart. There is some validity but I will take hold opinion until I appear into it further. Great article , thanks and we want more! Added to FeedBurner as well 362674

    Reply
  2. 27462 762136This internet page is actually a walk-through its the internet you desired with this and didnt know who need to have to. Glimpse here, and you will definitely discover it. 362296

    Reply
  3. 27776 930632The next time I just read a weblog, I truly hope which it doesnt disappoint me up to this 1. Get real, Yes, it was my choice to read, but I personally thought youd have something intriguing to convey. All I hear can be a handful of whining about something you could fix in the event you werent too busy trying to locate attention. 632568

    Reply
  4. 279520 581260Hey, you used to write fantastic, but the last few posts have been kinda boringK I miss your super writings. Past several posts are just a little bit out of track! come on! 684990

    Reply

Leave a Comment