Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scrolling table

Status
Not open for further replies.

rmagan

Programmer
Jun 3, 2003
35
US
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=&quot;1&quot; cellspacing=0 cellpadding=2 id=&quot;teacher_gradebook&quot;>
<TR>

<TD BGCOLOR=&quot;red&quot; align=&quot;center&quot; nowrap>
<input type=&quot;text&quot; name=&quot;p_grd_score&quot; size=&quot;5&quot; maxlength=&quot;5&quot; value=&quot;100&quot; id=&quot;100&quot;
onKeyDown=&quot;switch(event.keyCode) {case 40: return false; break;
case 13: return false; break;
case 38: return false; break;}
'&quot;></TD>
</TR>
</TABLE>


<script language=&quot;javascript&quot;>');
var tb = document.getElementById('teacher_gradebook').getElementsByTagName('tbody')[0];');
var xx;
function startScroll(dir){');
if (dir == 'U')
xx = setInterval(&quot;scrollUp()&quot;, 300);
else
xx = setInterval(&quot;scrollDown()&quot;, 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>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top