lentin
11-26-2003, 08:54 PM
Completely new to javascript and useless at everything else, but trying hard.
I have a table with 28 rows and 23 columns. I want to increment the row headings by one week (starting 14/04/2004).
Also am I able to reference the cells ie r1c1, r6c10 etc and if so how (just in case anyone wanted to just say yes)
Thanks for your help
Gollum
11-27-2003, 03:58 AM
lentin,
here's an example of (I hope) the sort of thing you are saying...
<html>
<head>
<script type="text/javascript">
function cell(id,i,j)
{
var oTable = document.getElementById(id);
return oTable.rows[i].cells[j];
}
function edit(id,i,j)
{
i++; // add one for header row
cell(id,i,j).innerHTML = '<input style="width:' + cell(id,i,j).clientWidth + 'px;" type=text value="' + cell(id,i,j).innerHTML + '" onblur="cell(\'' + id + '\',' + i + ',' + j + ').innerHTML = this.value;">';
cell(id,i,j).firstChild.focus();
}
</script>
</head>
<body>
<table id='theGrid' border=1>
<tr>
<script type="text/javascript">
var d = new Date(2004,4,14);
for ( i = 0; i < 28; i++ )
{
document.write('<th>' + d.getDate() + '/' + d.getMonth() + '/' + d.getYear() + '</th>');
d.setTime(d.getTime() + 7 * 24 * 3600 * 1000);
}
</script>
</tr>
<script type="text/javascript">
for ( i = 0; i < 23; i++ )
{
document.write('<tr>');
for ( j = 0; j < 28; j++ )
{
document.write('<td>R' + i + 'C' + j + '</td>');
}
document.write('</tr>');
}
</script>
</table>
<br><button onclick="edit('theGrid',10,10);">Edit</button>
</body>
</html>
have fun :D
lentin
11-28-2003, 05:16 AM
Gollum
Thanks very much for your help
Len