Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    England, Hythe
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts

    problme with sorting

    i am trying to sort a colum in my table by asc or desc i am trying to do it like this at the monet


    <script language="VBScript">
    dim mbOrder, s

    sub headerclick(sort)

    mborder = not mborder

    if mborder then
    window.location.href = "viewjobs.asp?sortby=" & sort & "&SortOrder=1"
    else
    window.location.href = "viewjobs.asp?sortby=" & sort & "&SortOrder=0"
    end if

    s = window.location.href

    msgbox(s)

    end sub

    </script>

    <a href="#" onclick="headerclick('jobtitle')">Job Title<img src="../images/up.gif" border="0"></a>

    so when the user clicks on the title is sorts it by ASC then if you click it again by DESC.

    please can some one help me, or if there is an easyer way do tell

    thank you very much for the help

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm not sure what your problem here is. Could you give more detail on what the problem is?

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I know what BlueMonkey is trying to do... I will provide some code tomorrow if I can remember, I have a perfectly working application that does exactly this.

    Wish you didn't have to wait but I have this code at work...
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    England, Hythe
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i need it to sort by ASC when the user clicks on the title of the colume and then when the page has reloaded and the user clicks on the same title it sorts by DESC

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here are the important parts of the code I'm using to do this:


    OrderBy = Request.QueryString("OrderBy")

    If OrderBy = "" Then OrderBy = "ID DESC"

    If InStr(1,OrderBy,"DESC") = False Then
    SortImage = "images/downarrow.gif"
    ReverseSwitchOrder = " DESC"
    SwitchOrder = ""
    Else
    SortImage = "images/uparrow.gif"
    ReverseSwitchOrder = ""
    SwitchOrder = " DESC"
    End If


    For Each fld In rs.Fields
    Response.Write(Indent(10) & "<td class=""productheader"" align=""center""><a class=""orderby"" href=""showreport.asp?Q=" & WhichReport & "&OrderBy=" & fld.Name)
    If InStr(1,OrderBy,fld.Name) > 0 Then
    Response.Write(ReverseSwitchOrder)
    Else
    Response.Write(SwitchOrder)
    End If
    Response.Write(""">" & Replace(fld.Name,"_"," ") & "</a><br />")
    If InStr(1,OrderBy,fld.Name) > 0 Then
    Response.Write("<img src=""" & SortImage & """ width=""10"" height=""10"" alt="""" />")
    Else
    Response.Write("<img src=""images/space.gif"" width=""10"" height=""10"" alt="""" />")
    End If
    Response.Write("</td>" & vbCrLf)
    fldcount = fldcount + 1
    Next

    Make any sense?
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oops, then of course I use this:

    MyQuery = "SELECT * FROM TableName ORDER BY " & OrderBy
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Location
    England, Hythe
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for the help


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •