From 2010.igem.org
(Difference between revisions)
|
|
Line 1: |
Line 1: |
- | <html>
| |
- | <head>
| |
| | | |
- | <script type="text/javascript">
| |
- | <!--
| |
- | Array.prototype.shuffle = function() {
| |
- | for (var i = 0; i < this.length; i++) {
| |
- | // Random item in this array.
| |
- | var r = parseInt(Math.random() * this.length);
| |
- | var obj = this[r];
| |
- |
| |
- | // Swap.
| |
- | this[r] = this[i];
| |
- | this[i] = obj;
| |
- | }
| |
- | }
| |
- | function randomize(tableID) {
| |
- | var myTable = document.getElementById(tableID);
| |
- | var myRows = new Array();
| |
- | for (i=myTable.rows.length-1; i>=0; i--) {
| |
- | var theRow = myTable.rows[i];
| |
- | myRows.push(theRow);
| |
- | theRow.parentNode.removeChild(theRow);
| |
- | }
| |
- | myRows.shuffle();
| |
- | for (j=0; j<myRows.length; j++) {
| |
- | myTable.appendChild(myRows[j]);
| |
- | }
| |
- | }
| |
- | window.onload = function() {
| |
- | randomize("randomtable1");
| |
- | randomize("randomtable2");
| |
- | }
| |
- | //-->
| |
- | </script>
| |
- |
| |
- | </head>
| |
- | </html>
| |
Latest revision as of 10:11, 21 June 2010