How do I sort fields by selection ascending or descending
How to do I go about dynamically sorting fields (ascending or descending) by clicking links for the respective field?
I've created in Dreamweaver MX 2004 the following:
A form with a single textbox called "search" and a table with 4 columns and 2 rows (the first row containing the titles and the second a repeat region contains the data fields) the first row contains the text (from left to right):
"Customer Reference Number", "Consignment Number", "Date" and "Courier".
The second row contains the actual fields grabbed from a SQL server using OLE (in a previous version I used a ODBC DSN).
I've thus far set it up so if someone enters a reference number (beginning numbers) it will then fetch all reference numbers which match sorted by ascending order, this then gives the user the consignment number (which they didn't know, which was what they were wanting), the date of the order and the courier being used.
I have also got it doing some other nice stuff like not displaying anything if the "search" field is null and it providing a dynamically generated link to the couriers website depending on the consignment number straight to the order itself on their website.
Now, what i'm wanting to do is so a user can click on any of the text of the four selections in the first row and it will then sort either by ascending or descending depending on which was clicked.
For example, if I clicked on "Date" it would then sort the existing fields (it would need to keep the current customer reference number entered for all of these) and it would then sort by ascending order, if date were clicked again then it would sort by descending order, same also goes for "consignment number" it would sort by ascending then descending for all of the second row (and all supsequent rows depending on how many records there were).
I have a few ideas on how to go about it, but I figured may as well save myself some time if anyone here know's how to do what i'm wanting.
A good example is on ebuyer.com's site, where you can click on price etc and it sorts by either ascending or descending.
Mark
Comments
example with up/down images
Create your SQL statement where your SORT BY clause is variable and determined by your QueryString:
In your webpage you use an up/down image for each column you want to be sortable, so the user can select ASC/DESC for a specific column:
On the up/down images you create hyperlinks that reload the page with the ASC/DESC QueryString:
<a href="Resultpage.asp?sort=DESC"><img src="up.gif" alt="DESC"></a>
<a href="Resultpage.asp?sort=ASC"><img src="down.gif" alt="ASC"></a>
Could you make this an extension
You must me logged in to write a comment.