Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is this even possible ???? 2

Status
Not open for further replies.

JrClown

Technical User
Oct 18, 2000
393
0
0
US
Hello all
I have a results page pulling form an Access database using ASP, my question is. Is there a way to sort the RESULTS page by simply clicking on the table header? or am I crazy for asking this? :)


Top of my Page

<%
sql = &quot;Select * from entries order by dateordered&quot;
Dim RSresults
set RSresults=server.createobject(&quot;ADODB.recordset&quot;)
RSresults.open sql, &quot;DSN=clients&quot;
%>

<table border=&quot;0&quot;>
<tr>
<td width=&quot;33%&quot; align=&quot;left&quot;>First</td>
<td width=&quot;33%&quot; align=&quot;left&quot;>Last</td>
<td width=&quot;34%&quot; align=&quot;left&quot;>Date Ordered</td>
</tr>

<%
Do While Not RSresults.EOF
%>

<tr>
<td width=&quot;33%&quot;>John</td>
<td width=&quot;33%&quot;>Smith</td>
<td width=&quot;34%&quot;>3/1/01</td>
</tr>

<%
RSresults.MoveNext
LOOP
%>

</table>
QUOTE OF THE DAY
Don't waste time telling people what you are doing or what you are going to do. Results have a way of informing the world.

<%
Jr Clown :eek:)
%>
 
create an active-x control which does this sorting of data using vb events ,functions and scripting and then insert it as an object in the html page using <OBJECT> tag by specifying its class id.
 
> . Is there a way to sort the RESULTS page by simply clicking on the table header?

Of course there is. The simplest most often implemented approach involves going back to the server and re-querying the data with a different &quot;order by&quot; clause then displaying the table as ususal.

Other client side techniques are possible but they are much more complex and contain browser dependancies.

Hope this helps
-pete
 
The simplest way to do what Pete is talking about is to create a form with nothing but hidden elements, and with the action pointing to the same page (recursive)...

For instance, you make the table headers links, of course, and each link is something like &quot;javascript:sortFunction(yourCriteria)&quot;...

and then the function would look something like this:
Code:
sortFunction(sortCriteria){
   document.nameOfYourForm.theHiddenElementName.value=sortCriteria;
}

Then at the beginning of the page, you have some asp script that will check for the values of the form elements like
Code:
if request.form(&quot;theHiddenElementName&quot;) = soAndSo then
   sql = sql & &quot; ORDER BY &quot; & soAndSo
end if
Where soAndSo is your search criteria that the javascript function set...

Just make sure that when you make the form in your html, make the value for the hidden elements originally set to &quot;&quot;, like
Code:
<form name=&quot;nameOfYourForm&quot; action=&quot;thisPage.asp&quot; method=&quot;post&quot;>
   <input type=hidden name=theHiddenElementName value=&quot;&quot;>
</form>

And it's only set to an actual value if the user clicks on the table header... sort of like a control... and you can check for empty strings to ensure what the user clicked.

Hope it made sense. :)
Paul Prewett
 
(assumes on the serverside, you are using a recordset)

you could do it all on client side (either with activeX control) by using DHTML, the only problem is, that it would take some work to make your ASP generate this (tho I think as long as some of the coloumns are not just numbers, or indexed differently) by placing names on each table cell, and such, so that when you click it, it finds every guy with that index reference, also containing the name, but then you will need to develop some sort of javascript to be able to sort it for you, as well as sorting the rest of the colums that moves with it, basically your only two easy options are

1) Re-call the ASP , with new sort (as sugested above)
2) create an ActiveX , that acts as a dataview

I have done both before, requery is good, if you have your records in pages, such as I had mine made to do 10 record paging, so whenever I sorted the page would come back down quickly (but since it requeried it, it did sort the whole thing like its supposed to, the download time was just shorter cuz it was smaller view of the database)

the activeX way of doing it is ok, but you still have some of that client side setup required, I recomend looking into the recordset.save method, this can save a persistant recordset, then you can in the activeX control download it from a known path given to it. Karl
kb244@kb244.com
Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)

 
You can do the whole thing in the client side, with out reloading the ASP page form the server, or building an ActiveX. I have done it before.
You can build javascript sorter that will do some sorting algorethem on the required column,such like bubble sort, and before that it can detect the type of data in that field, such like numbers or dates, so you can you the proper comparsions on these data.
This is a DHTML method, so it is not working with browsers not supporting DHTML.

I can send you this script if you want, mail me at:
zyadbasim@hotmail.com
 

Thank you very much for all your input fellas. I'll look in to them. QUOTE OF THE DAY
Don't waste time telling people what you are doing or what you are going to do. Results have a way of informing the world.

<%
Jr Clown :eek:)
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top