gnanesh
05-12-2003, 06:17 AM
folks
I have around 25 rows in a Table and i do not like to display all the records at time, so i need to know how to display 5 rows at a time & by having a Next button , i need to show the user next set of records , If any one have code for this please let me know
Thanks
GG
Gollum
05-12-2003, 07:31 AM
Something like this should do the trick...
<html>
<head>
<script language="Javascript">
var data =
[
["Row 1", "blah blah blah", ...],
["Row 2", "blah blah blah", ...],
["Row 3", "blah blah blah", ...],
...
["Row N", "blah blah blah", ...]
];
var nRow = 0;
function Scroll(n)
{
nRow += n;
if ( nRow < 0 ) nRow = 0;
if ( nRow >= data.length ) nRow -= n;
var aStr = new Array;
aStr.push('<table>');
for ( var i = nRow; (i < nRow + 5) && (i < data.length); i++ )
{
aStr.push('<tr>');
for ( var j = 0; j < data[i].length; j++ )
{
aStr.push('<td>' + data[i][j] + '</td>');
}
aStr.push('</tr>');
}
var oDiv = document.getElementById('TheTable');
oDiv.innerHTML = aStr.join('');
}
</script>
</head>
<body onload="Scroll(0);">
<div id="TheTable"></div>
<button onclick="Scroll(-5);">Page Back</button>
<button onclick="Scroll(5);">Page Forward</button>
</body>
</html>