tags:

views:

75

answers:

1

Actually I have a table in which I have fetched the records from the database, and am intending to do the sorting for the records.

"My intention is to have a small button near the headers of the table and whenever I click that button then the records should get sorted".

I am providing a piece of Perl code here which can make the things more clear of what am I up to:

 print "<th >$sth->{NAME}->[0] <input type=\"submit\" name=\"Id\" 
      value=\"v\"></th>"; 

Here the button would look like "v" and whenever I click that button then it should sort and the button would look like "^".

Can I make such an interface and sort the records?

+4  A: 

The best way to do this is probably on the client side. In which case it becomes a Javascript question rather than a Perl one. I'd be surprised if jQuery didn't make this incredibly easy.

davorg
Thanks Mr.davorg, but can i get more information as in how to proceed further as i am intending to get it done? Please do guide me.
sonya
You'd be better off asking people who know Javascript and jQuery I expect. But Googling for "jquery sort table" gave me http://tablesorter.com/docs/ as the first result.
davorg
Actually i went through the tablesorter link, i followed the instruction and placed the code but it gave me error(somr synyax error),frankly speaking till now i havent used any javascript in my code,it was all complete perl so i have no idea about jquery and sos on. Is jquery / javascript the only way to set the sorting method working?
sonya
You said you wanted client-side sorting. Javascript is the only way to implement client-side functionality like this.
davorg
ok thank you i will go through the link again and try to get it done.
sonya
With some of the Javascript toolkits, it's almost trivial to do this nowadays. :)
brian d foy