<html> <head> <meta http-equiv="content-type" content="text/html;charset=Windows-1252"> <script type="text/javascript"> var people, asc1 = 1, asc2 = 1; window.onload = function() { people = document.getElementById("people"); } function sort_table(tbody, col, asc) { var rows = tbody.rows, rlen = rows.length, arr = new Array(), i, j, cells, clen; // fill the array with values from the table for (i = 0; i < rlen; i++) { cells = rows[i].cells; clen = cells.length; arr[i] = new Array(); for (j = 0; j < clen; j++) { arr[i][j] = cells[j].innerHTML; } } // sort the array by the specified column number (col) and order (asc) arr.sort(function(a, b) { return (a[col] == b[col]) ? 0 : ((a[col] > b[col]) ? asc : -1 * asc); }); // replace existing rows with new rows created from the sorted array for (k = 0; k < rlen; k++) { rows[k].innerHTML = "<td class='tdclass'>" + arr[k].join("</td><td class='tdclass'>") + "</td>"; } } function selectRadio() { var radioValue=""; if (document.getElementById('radioId1').checked) { sort_table(people, 2, asc1); asc1 *= -1; asc2 = 1; } else if (document.getElementById('radioId2').checked) { sort_table(people, 2, asc2); asc2 *= -1; asc1 = 1; } } </script> <body> <br/> <br/> <table> <tr> <td class="tdheadclass"><input type="button" value="Main Menu" /><span class="tab"></span></td> <td class="tdheadclass"><input type="button" value="New Search" /><span class="tab"></span></td> <td class="tdheadclass"> <input type="radio" id="radioId1" name="radioId" value="Id" checked>Id <input type="radio" id="radioId2" name="radioId" value="Email Id">Email Id<span class="tabLess"></span> <input type="button" value="Sort by" /> </td> <td class="tdheadclass"><input type="button" value="Save As" /><span class="tab"></span></td>
Quote:How do I write sort by option in JavaScript?
Quote:it's working all other browsers and IE 11 as well.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)