Question

I'm looking to get a title of the specific item that is being selected on my page:

function response(jsonData) {
    var items = jsonData["items"];
    var tDiv = document.getElementById("dynamicVideos");
    var uDiv = document.getElementById("videoInfo");
    var i=0;        

    while (i<items.length) {        

        var str = "";
        str += '<div class="tvVideo">';
        str += '<div class="thumb" onClick="playTitleFromList(' + items[i].id + ')"><img src="' + items[i].thumbnailURL + '"/></div>';
        str += '<p class="vidTitle">' + items[i].name + ' (' + formatTime(items[i].length) + ')'+ '</p>';
        str += '<p class="vidDescription">' + items[i].shortDescription + '</p>';
        str += '</div>';

        tDiv.innerHTML += str;

        i++;
    }

    var str2 = "";
    str2 += '<div class="videoTitle">';
    str2 += '<h3 id="videoTitle">' + items[0].name + '</h3>';
    str2 += '</div><!-- Video Title -->';
    str2 += '<div class="videoDescription">';
    str2 += '<p id="videoDescription">' + items[0].longDescription + '</p>';
    str2 += '</div><!-- Video Description -->';
    str2 += '<div class="divide"></div>';
    str2 += '<div id="videoDonate"></div>';
    str2 += '<div id="videoTAF"></div>';
    str2 += '<div id="videoTime"></div>';

    uDiv.innerHTML += str2;
}

The bottom portion of the code should display the video selected's info as the top code block returns the list of video.

Was it helpful?

Solution

If by "selected" you mean the last item you've clicked, you'll need to add code to playTitleFromList to populate your page with the data. That function will need access to the same data that's in jsonData so it has the values it needs. That function is currently passed the ID that needs to be looked up; alternately, you could change the code so that i is passed as the parameter rather than the id so that you can just access the item in the array.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top