Advertisement
KillianMills

SortAndToggleButton.js

May 28th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script src="sorttable.js"></script>
  2. <script src="Scripts/jquery-1.3.2.js"
  3.     type="text/javascript"></script>
  4.    
  5. <script>
  6.  
  7.     table1 = "hyperTable";
  8.     holder1 = "hyperButtonHolder";
  9.     table2 = "hostTable";
  10.     holder2 = "hostButtonHolder";
  11.     table3 = "pathsTable";
  12.     holder3 = "pathsButtonHolder";
  13.  
  14.     function initialSorting() {
  15.         // Initial sorting on hostname
  16.         sorttable.innerSortFunction.apply(document.getElementById('hostnameHV'), [])
  17.         sorttable.innerSortFunction.apply(document.getElementById('hostname'), [])
  18.         sorttable.innerSortFunction.apply(document.getElementById('hostnamePathing'), [])
  19.     }
  20.    
  21.     function makeButtons(tableName, holderName){
  22.    
  23.         var tableWidth = document.getElementById(tableName).rows[0].cells.length;   // width of the table
  24.         var tableHolder = document.getElementById(tableName).rows[0].cells;         // holds the column headers
  25.         var stringIdentity = document.getElementById(tableName);                    // holds a string with the table name
  26.    
  27.         //make buttons for each column
  28.         for (var i = 1; i < tableWidth; i++) {
  29.             //make buttons
  30.             document.getElementById(holderName).innerHTML+=('<input type="button" id="removeColButton'+i+'" value="'+tableHolder[i].innerHTML+'" onclick="removeCol('+(i+1)+', '+tableName+')"/>');
  31.        
  32.         }
  33.     }
  34.    
  35.     function removeCol(columnNum, chosenTable) {
  36.    
  37.         var input = parseInt(columnNum); // turns columnNum into an int
  38.         var idHolder = chosenTable.id;   // stores id of table
  39.  
  40.         // if hidden; show. if shown; hide
  41.         $('#'+idHolder+' th:nth-child('+input+'),#'+idHolder+' td:nth-child('+input+')').toggle();
  42.     }
  43.    
  44. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement