var output = "";
for (var i = 0; i < result.lenght; i++) {
output +=
'<div class="movies">' +
'<h3>Titel: ' + result[i].Title + '</h3>' +
'<p>Year: ' + result[i].Year + '</p>' +
'</div>';
document.getElementById('result').innerHTML = output[i];
}
You have declared
output
as a simple string, but you then try to add the first character ('
<
') to the
result
field in the web page. You should create a single
div
field and then add all the movie details one by one to the
output
variable. Then when you have completed the list you pass it to
result
.
var output = '<div class="movies">';
for (var i = 0; i < result.lenght; i++) {
output +=
'<h3>Titel: ' + result[i].Title + '</h3>' +
'<p>Year: ' + result[i].Year + '</p>' +
}
output += '</div>';
document.getElementById('result').innerHTML = output;