Toggle Onclick Between Ascending En Descending Date Using Php
I have got this problem. I am trying to make a function where I can sort results by dates in a table. So far I got this: function wedstrijdenClub (){ $laMatches = WaterpoloAP
Solution 1:
The JS part you need is really simple i think :
jQuery(document).on('click','a.asc, a.desc',function(e){
e.preventDefault() ;
jQuery('div.block').hide() ;
jQuery('div.'+jQuery(this).attr('class')).show() ;
}) ;
div.asc, { display:block ; }
div.desc { display:none ; }
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="block asc">A B C D E F</div><divclass="block desc">F E D C B A</div><aclass="asc">Asc</a><aclass="desc">Desc</a>
Just be carefull with your php part : when you use usort function, the value of $laMatches is changed, so calling 2 times usort will only show you the last results.
You need to make copies of your $laMatches and sort the copies :
$laMatches = Array('red','blue','green','brown','yellow') ;
$asc = $laMatches ;
$desc = $laMatches ;
usort($desc, function($a, $b) {
return strlen($a) - strlen($b) ;
});
usort($asc, function($a, $b) {
return strlen($b) - strlen($a) ;
});
echo'<div class="asc">'.implode('<br />',$asc).'</div>' ;
echo'<div class="desc">'.implode('<br />',$desc).'</div>' ;
Post a Comment for "Toggle Onclick Between Ascending En Descending Date Using Php"