here is my issue:
when i say getelementbyid("table1") it says"Uncaught TypeError: Cannot set property 'innerHTML' of null"
i am rendering a dynamic table via java script asshown below:
function mainProcessing()
{
<% ProductController pc=new ProductController();%>
var val = <%=pc.doTask()%>
var jobj=JSON.stringify(val);
document.write(jobj);
alert(jobj);
var obj=JSON.parse(jobj);
alert("jobj");
alert(obj.toString());
var object = eval("(" + jobj+ ")");
alert("this part is done");
return object;
}
function drawtable()
{
var JSONObj=mainProcessing();
var tablecontents = "";
for (var i = 0; i < 5; i ++)
{
tablecontents += "<tr>";
tablecontents += "<td>" + i + "</td>";
tablecontents += "<td>" + i * 100 + "</td>";
tablecontents += "<td>" + i * 1000 + "</td>";
tablecontents += "</tr>";
}
document.write(JSONObj.toString());
alert("just outside nested loop");
document.getElementById("table1").innerHTML = tablecontents;
}
for testing i have inserted randome values in the table.
and that html part goes like this:
<title>Indian Divine !!!</title>
</head>
<body onload="drawtable()">
<center>
<h1>my name is jobj</h1>
<table id="table1">
</table>
</center>
</body>
</html>
the browser user is Chrome. IDE Eclips Juno