Well Jay I think the easiest way to do this is to redirect to the same
ASP with an option (thispage.asp?sort=3D1). This will be a bit easier
because you can let ADO do the sorting for you. When you get your
Recordset before you display it you can do this Rs.Sort =3D "fieldname"
or "fieldname". This will sort your recordset by 1 of the fields in
ascending or descending order. Then all you need to do is let your page
run as normal and your list will now show as sorted.
If you want to do it with JavaScript its going to be a lot more
complicated than the 10 or so lines of code you would need to add for
the ASP to do it.
if Request("sort") <> "" then
Select case Request("sort")
Case "1"
Rs.Sort=3D"fieldname1"
Case "2"
Rs.Sort=3D"fieldname2"
Case "n"
Rs.Sort=3D"fieldnamen"
End Select
End if
hope this helps
Keith
----- Original Message -----
From: "Jay Vit" <jay48202@y...>
To: "JavaScript HowTo" <javascript_howto@p...>
Sent: Wednesday, December 11, 2002 5:34 PM
Subject: [javascript_howto] sort option in the table of the asp page
> Hi,
>
> I am displaying values from database in a tabular format in ASP page.
Now,
> I wanna sort them with a click on the column header. I would
appreciate,
> if you people help me out. I am newbie to programming.
>
>
> <HTML>
> <Body>
> <table width=3D100% border=3D1>
> <tr bgcolor=3D"silver">
> <th align=3Dleft width=3D"66"><font
color=3D"blue">Sequence</font></th>
> <th align=3Dleft width=3D"80"><font
color=3D"blue">PartNumber</font></th>
> <th align=3Dleft width=3D"254"><font color=3D"blue">Part
Type</font></th>
> <th align=3Dleft width=3D"66"><font
color=3D"blue">Customer</font></th>
> <th align=3Dleft width=3D"62"><font color=3D"blue">Date</font></th>
> </tr>
>
> <% ' cycle through the record set and display each row results
> do until RS.EOF %>
> <tr>
> <td width=3D"80"><font size=3D-1><%=3D RS.Fields(0)%><font
size=3D-1></td>
> <td width=3D"80"><font size=3D-1><%=3D RS.Fields(1)%><font
size=3D-1></td>
> <td width=3D"254"><font size=3D-1><%=3D RS.fields(2)%><font
size=3D-1></td>
> <td width=3D"66"><font size=3D-1><%=3D RS.fields(3)%><font
size=3D-1></td>
> <td width=3D"62"><font size=3D-1><%=3D RS.fields(4)%><font
size=3D-1></td>
> </tr>
> <% ' increment record position with MoveNext method
> RS.MoveNext
> loop
> %>
> </Body>
> </HTML>
>
> Thanks,
> Jay
>