Entry
How can i add a Table on click of a button.
Feb 19th, 2002 02:36
suresh kc, Sumegha,
you can generate the contents dynamically. If the content you display
in the table changes from time to time you can simply use the
.innerHTML property of the layer where you wish to display the table.
otherwise if the table contents remain constant, you can use the
.visibility property of the layer to hide or show the layer
sample code:
<html>
<head>
<script language=Javascript>
var tableContents = "<table><tr><td>";
tableContents += "This is a demo ";
tableContents += "only</td></tr></table>";
function changeContents() {
document.myDIV.innerHTML = tableContents;
}
function showTable() {
if(document.all)
document.all.myDIV2.style.visibility = "visible";
else
document.myDIV2.visibility = "visible";
}
</script>
</head>
<body>
<DIV ID=myDIV STYLE="position:absolute;left:10 px;top:100 px;">
</DIV>
<DIV ID=myDIV2 STYLE="position:absolute;left:10 px;top:250
px;visibility:hidden;">
<table><tr><td>Visibility</td></tr></table>
</DIV>
<DIV ID=restOFTHEHTML STYLE="position:absolute;left:10 px;top:50 px;">
<form>
<input type=button value="Generate Table"
onClick="changeContents();">
<input type=button value="Show Table"
onClick="showTable();">
</form>
</DIV>
</body>
</html>