

<html>
<head>
<title>2009 Sec B</title>
<script type="text/javascript" >

function dynamic_table()
{
var head = prompt("Input Headline","");
var cols = prompt("Input No of Colomns","");
var rows = prompt("Input No of Rows","");

document.write("<h1>" +head +"</h1>");

document.write("<table border='2' colspace='3' colspan='3'>");

for(var i=1; i<=rows; i++)
{
if(i%2 == 1)
{
document.write("<tr style='background-color:red'>");
}
else
{
document.write("<tr style='background-color:green'>");
}

for(var j=1; j<=cols; j++)
{
document.write("<td> row = " +i +"col = " +j);
document.write("</td>");
}

document.write("</tr>");
}

document.write("</table>");
}
</script>
</head>

<body>
<input type="button" value="Draw Table" onclick="return dynamic_table();"/>
</body>
</html>










