/    Sign up×
Community /Pin to ProfileBookmark

Pictures not showing

I updated my code and I cant seem to figure out why my pictures are not showing when I open the webpage

  • * Filename: photos.js
    */
  • “use strict”; // interpret document contents in JavaScript strict mode

    /* global variables */
    var photoOrder = [1,2,3,4,5];

    /* shift all images one figure to the left, and change values in photoOrder array to match */
    function rightArrow() {
    for (var i = 0; i < 5; i++) {
    if ((photoOrder[i] + 1) === 6) {
    photoOrder[i] = 1;
    } else {
    photoOrder[i] += 1;
    }
    populateFigures();
    }
    }

    /* shift all images one figure to the right, and change values in photoOrder array to match */
    function leftArrow() {
    for (var i = 0; i < 5; i++) {
    if ((photoOrder[i] – 1) === 0) {
    photoOrder[i] = 5;
    } else {
    photoOrder[i] -= 1;
    }
    populateFigures();
    }
    }
    /* create event listeners for left arrow, right arrow, and center figure element */
    function createEventListeners() {
    var leftArrow = document.getElementById(“leftArrow”);
    if (leftArrow.addEventListener){
    leftArrow.addEventListener(“click”, leftArrow, false);
    } else if (leftArrow.attachEvent) {
    leftArrow.attachEvent(“onclick”, leftArrow);
    }
    var rightArrow = document.getElementById(“rightArrow”);
    if (rightArrow.addEventListener){
    rightArrow.addEventListener(“click”, rightArrow, false);
    } else if (rightArrow.attachEvent) {
    rightArrow.attachEvent(“onclick”, rightArrow);
    }
    var mainFig = document.getElementsByTagName(“img”)[1];
    if (mainFig.addEventListener) {
    mainFig.addEventListener(“click”, zoomFig, false);
    } else if (mainFig.attachEvent) {
    mainFig.attachEvent(“onclick”, zoomFig);
    }
    }
    /* add src values to img elements based on order specfied in photoOrder array */
    function populateFigures () {
    var filename;
    var currentFig;
    for (var i = 1; i < 4; i++) {
    filename = “images/IMG_0” + photoOrder[i] + “sm.jpg”;
    currentFig = document.getElementsByTagName(“img”)[i – 1];
    currentFig.src = filename;
    }
    }
    /* open center figure in separate window */
    function zoomFig() {

    }

    /* create event listeners and populate image elements */
    function setUpPage() {
    createEventListeners();
    populateFigures();
    }

    /* run setUpPage() function when page finishes loading */
    if (window.addEventListener) {
    window.addEventListener(“load”, setUpPage, false);
    } else if (window.attachEvent) {
    window.attachEvent(“onload”, setUpPage);
    }

    to post a comment
    JavaScript

    2 Comments(s)

    Copy linkTweet thisAlerts:
    @benmartin101Oct 08.2015 — On the addEventListener for the leftArrow, rightArrow, and mainFig, I believe there should be function callbacks in the parameters, like you did with window.addEventListener().
    Copy linkTweet thisAlerts:
    @SempervivumOct 08.2015 — The common candidates for the reason are: Misspelling of the filename / directory name, upper and lower case, wrong directory ... If the page is online, please post the URL. Or a screenshot of the directory listing for the images.
    ×

    Success!

    Help @mschneider331 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.28,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...