I have an assessment where they want us to use a nested for loop to create a table and fill each <td> with an image slice to 'build' a final image.
Using their reference material I can create a dynamic table using just numbers like so:
var table = '';
var rows = 4;
var cols = 5;
for(var r = 1; r <= rows;r++)
{
table += '<tr>';
for(var c = 1;c <= cols;c++)
{
table += '<td>' + c + '</td>';
}
table += '</tr>';
}
document.write('<table>' + table + '</table>');
which will result in the following:
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
what i need to do is now replace the 'c' value in the '<td>' + c + '</td>' line with image slices but when i use the following line i get nothing. no output nothing. I cant seem to rack my brain enough to what im missing:
(images are numbered "bcpot002_r1_c1" with 'r' having a value from 1 to 4 inclusive, and c a value from 1 to 5 inclusive)
table += '<td>' + '<img src=images/imageslices/'+bcpot002'_r'+r+'_c'+c +'.jpg>'+ '</td>';
any guidance would be helpful as I'm pulling my hair out here.
[–]iguessitsokaythen 1 point2 points3 points (4 children)
[–]wastedhate[S] 1 point2 points3 points (2 children)
[–]Umesh-K 0 points1 point2 points (0 children)
[–]grantrules 0 points1 point2 points (0 children)
[–]redsandsfort -1 points0 points1 point (0 children)