I am trying to implement a scrolling table. This will keep the <THEAD> static while the <TBODY> scrolls up/down. I would like to call the function when the user hits the enter key (scroll down 1 row), down arrow (scroll down 1 row) and up arrow (scroll up 1 row). I have some of the code but I need help on:
1) only scrolling 1 row at a time when the appropriate key is entered.
2) Calling the scroll function from the appropriate key code
<TABLE width=100% height=93% border="1" cellspacing=0 cellpadding=2 id="teacher_gradebook">
<TR>
<TD BGCOLOR="red" align="center" nowrap>
<input type="text" name="p_grd_score" size="5" maxlength="5" value="100" id="100"
onKeyDown="switch(event.keyCode) {case 40: return false; break;
case 13: return false; break;
case 38: return false; break;}
'"></TD>
</TR>
</TABLE>
<script language="javascript">');
var tb = document.getElementById('teacher_gradebook').getElementsByTagName('tbody')[0];');
var xx;
function startScroll(dir){');
if (dir == 'U')
xx = setInterval("scrollUp()", 300);
else
xx = setInterval("scrollDown()", 300);
}
function scrollUp(){
// -- get the tbodys first child (tr)
var r1 = tb.childNodes[0];
if (r1)
tb.appendChild(r1);
}
function scrollDown(){
var r1 = tb.childNodes[0];
// -- get the tbodys last child (tr)
var rLast = tb.childNodes[tb.childNodes.length - 1];
if (rLast)
tb.insertBefore(rLast, r1);
}
function stopScroll(){
if (xx != null)
clearInterval(xx);
}
</script>
1) only scrolling 1 row at a time when the appropriate key is entered.
2) Calling the scroll function from the appropriate key code
<TABLE width=100% height=93% border="1" cellspacing=0 cellpadding=2 id="teacher_gradebook">
<TR>
<TD BGCOLOR="red" align="center" nowrap>
<input type="text" name="p_grd_score" size="5" maxlength="5" value="100" id="100"
onKeyDown="switch(event.keyCode) {case 40: return false; break;
case 13: return false; break;
case 38: return false; break;}
'"></TD>
</TR>
</TABLE>
<script language="javascript">');
var tb = document.getElementById('teacher_gradebook').getElementsByTagName('tbody')[0];');
var xx;
function startScroll(dir){');
if (dir == 'U')
xx = setInterval("scrollUp()", 300);
else
xx = setInterval("scrollDown()", 300);
}
function scrollUp(){
// -- get the tbodys first child (tr)
var r1 = tb.childNodes[0];
if (r1)
tb.appendChild(r1);
}
function scrollDown(){
var r1 = tb.childNodes[0];
// -- get the tbodys last child (tr)
var rLast = tb.childNodes[tb.childNodes.length - 1];
if (rLast)
tb.insertBefore(rLast, r1);
}
function stopScroll(){
if (xx != null)
clearInterval(xx);
}
</script>