Create an HTML page to take input data for a table & display the table using java script.
<html>
<head>
<title>Prashant Anand</title>
<script type=text/javascript>function createtable()
{
var x = document.createElement("TABLE");
var no_of_rows=parseInt(window.prompt("Enter the no. of rows"));
var no_of_cols=parseInt(window.prompt("Enter the no. of column"));
x.style.border = 1;
x.style.borderStyle = "solid";
for(i=0;i<no_of_rows;i++)
{
var new_row = document.createElement("tr");
x.appendChild(new_row);
for(j=0;j<no_of_cols;j++)
{
var new_col = new_row.insertCell(j);
var input = window.prompt("Enter value for cell (" + i + "," + j + "):");
new_col.innerHTML = input;
new_col.style.border = 1;
new_col.style.borderStyle = "solid";
new_row.appendChild(new_col);
}
}
document.body.appendChild(x);
}
</script>
</head>
<body onload="createtable();">
</body>
</html>
<head>
<title>Prashant Anand</title>
<script type=text/javascript>function createtable()
{
var x = document.createElement("TABLE");
var no_of_rows=parseInt(window.prompt("Enter the no. of rows"));
var no_of_cols=parseInt(window.prompt("Enter the no. of column"));
x.style.border = 1;
x.style.borderStyle = "solid";
for(i=0;i<no_of_rows;i++)
{
var new_row = document.createElement("tr");
x.appendChild(new_row);
for(j=0;j<no_of_cols;j++)
{
var new_col = new_row.insertCell(j);
var input = window.prompt("Enter value for cell (" + i + "," + j + "):");
new_col.innerHTML = input;
new_col.style.border = 1;
new_col.style.borderStyle = "solid";
new_row.appendChild(new_col);
}
}
document.body.appendChild(x);
}
</script>
</head>
<body onload="createtable();">
</body>
</html>
No comments:
Post a Comment