New test for moving rows via rowIndex assignment in javascript

This commit is contained in:
selmer%netscape.com 1999-11-29 23:58:37 +00:00
Родитель 50fd527b60
Коммит ef134cddbd
1 изменённых файлов: 51 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,51 @@
<html>
<script>
function moveRow(from, to)
{
if (from == -1 && to == -1)
{
var fromE = document.getElementsByTagName("INPUT")[0];
from = parseInt(fromE.value);
var toE = document.getElementsByTagName("INPUT")[1];
to = parseInt(toE.value);
}
var row = document.getElementsByTagName("TR")[from];
row.rowIndex = to;
}
function runTests()
{
alert("runTests");
// Test fails if final ordering differs from initial ordering
//
// Starting with order 0,1,2,3,4,5 shift through the rows and
// end up back where we started.
moveRow(0, 5);
moveRow(1, 4);
moveRow(2, 3);
moveRow(3, 2);
moveRow(4, 1);
moveRow(5, 0);
// Throw 2 out-of-bounds tests at the end and still get back to the starting point.
moveRow(5, -1);
moveRow(0, 6);
}
function delay()
{
setTimeout("runTests()", 9);
}
</script>
<body bgcolor=white onload="delay()">
<table>
<tr><td>Row 0</td></tr>
<tr><td>Row 1</td></tr>
<tr><td>Row 2</td></tr>
<tr><td>Row 3</td></tr>
<tr><td>Row 4</td></tr>
<tr><td>Row 5</td></tr>
</table>
<input type=text name=from value=2 size=1>
<input type=text name=to value=4 size=1>
<input type=button name=go value=go onclick="moveRow(-1,-1);">
</body>
</html>