I want to write a function to make user click the table header double click and change into descending or ascending order, and I have finished the sorting function, but don't know how to put together, now I just put one of them into the header as following:
function sortBy(sKey)
{
document.sortResultsForm.sSortBy.value=sKey;
document.sortResultsForm.submit();
}
if($sSortBy=="District")
{
usort($tempArr, 'sortDistrictNameascend');
}
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr> <td class="headTable" width=15%>
<a href="javascript:sortBy('District');"
><font color=white>District</font></a>
</td>
and I don't know how to put the other function into the header let user can double click to change sorting order, the order function as following:
function sortDistrictNamedescend($a, $b)
{
if ($a->DistrictName == $b->DistrictName)
{
return 0;
}
return ($a->DistrictName < $b->DistrictName) ? 1 : -1;
}
usort($tempArr, 'sortDistrictNamedescend');
anybody can help me, thank you very much.