I have this function that has a first loop that creates a dynamic javascript table.It then outputs the table to a htm. The second loop within it is to call a countdown clock function that outputs to the div tags created in the first loop. For now it only prints out in the first table entry. The second one is blank. How do I solve this?
function loadXMLDoc()
{
var table;
var i;
table=("<table>");
var x=xmlDoc.getElementsByTagName("Product");
for (i=0;i<x.length;i++)
{
table+=("<tr>");
table+=("<td> Time Left : </td>");
table+=("<td><div id="dday"></div></td>");
table+=("<td><div id="dhour"></div></td>");
table+=("<td><div id="dmin"></div></td>");
table+=("<td><div id="dsec"></div></td>");
table+=("</tr>");
}
table+=("</table>");
document.getElementById('listinglist').innerHTML=table;
var y=xmlDoc.getElementsByTagName("Product");
var z
for (z=0;z<y.length;z++)
{
countdown(yr,m,d,hr,min);
}
}
function countdown(yr,m,d,hr,min)
{
document.getElementById('dday').innerHTML="HH";
document.getElementById('dhour').innerHTML=dhour;
document.getElementById('dmin').innerHTML=dmin;
document.getElementById('dsec').innerHTML=dsec;
}
See Question&Answers more detail:os