Click to See Complete Forum and Search --> : built table
jolielady
03-25-2003, 01:41 PM
I have a question here...
I would like to make a script where people can enter the number of colomn and row by themself. As to be lik a form on the page and after they enter it, they can see the table....
Is anybody know and can help me. I'm kind of new in this and want to learn.
Thanks
Jolielady
havik
03-25-2003, 02:01 PM
Check this out:
It does everything you want to the most basic element. There's no error catching code, and it writes the table to a new page at the moment.
Havik
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript">
<!-- hide this script from incompatible web browsers
var rows = 0;
var cols = 0;
function getDimensions() {
rows = document.dimensions.rows.value;
cols = document.dimensions.cols.value;
writeTable();
}
function writeTable() {
document.write('<table cellspacing=5 cellpadding=5 border=1 bordercolor="black">');
for(var r = 0; r < rows; r++) {
document.write('<tr>');
for(var c = 0; c < cols; c++) {
document.write('<td width=5 height=5>test</td>');
}
document.write('</tr>');
}
document.write('</table>');
}
// End -->
</script>
</head>
<body>
<form name="dimensions">
Rows:<input name="rows" type="text"><br>
Cols:<input name="cols" type="text"><br><br>
<input type="button" value="Create Table" onclick="getDimensions()">
</form>
</body>
</html>
jolielady
03-25-2003, 02:08 PM
thanks havik. I'm sure this will help.