I have the following function:
<script>
function generateHtml(index)
{
document.write('Hello ' + index);
}
</script>
and I have a server side script generating the following html
<div><script>generateHtml(3)</script></div>
<div><script>generateHtml(4)</script></div>
in the hopes that Hello 3 and Hello 4 would be written in the page. However, this does not occur. Instead nothing is displayed. What is wrong with this approach?
Is it better to wrap the <div>'s is a id that can be selected and then change the html instead of writing to the DOM?