Sortable table

Results 1 to 3 of 3

Thread: Sortable table

  1. #1
    someone Guest

    Default Sortable table

    I have a table which is currently ordered by date. I want to give the user the option of clicking each column heading in order to sort them. E.g. If the user wishes to see her project listed in alphabetical order, she could click on PROJECT column. Is this possible???????

  2. #2
    Jason Buck Guest

    Default RE: Sortable table

    Yes, this is very possible.<BR><BR>You can do it by the request.querystring method.<BR><BR>Create the your column headings as hyperlinks with the and add a querystring to the end of it....<BR><BR>&#060;%<BR>strsort = request.querystring("sort")<BR><BR>strConnect = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=C:inetpubwwwrootmarketingdatabasespecdb.mdb"<B R><BR>dim objconn, objrec, mysql, strStatus, Mytest, strLength<BR>set objconn = server.createobject("ADODB.Connection")<BR><BR><BR >objConn.open strConnect<BR><BR><BR>mysql = "SELECT tblAttyInfo.Atty_ID, tblAttyInfo.Attorney_Name, tblAttyInfo.Administrative, tblAttyInfo.Antitrust, tblAttyInfo.Bankruptcy, tblAttyInfo.Closely_Held_Business, tblAttyInfo.Comm_Trans, tblAttyInfo.Condos, tblAttyInfo.Corp, tblAttyInfo.Criminal, tblAttyInfo.Dom_Reltns, tblAttyInfo.Emp_Ben, tblAttyInfo.Environmental, tblAttyInfo.Fin_Inst, tblAttyInfo.Franchise, tblAttyInfo.Health_Law, tblAttyInfo.Immigration, tblAttyInfo.Insurance, tblAttyInfo.Intl_Bus, tblAttyInfo.Intel_Prop, tblAttyInfo.Labor, tblAttyInfo.Lit, tblAttyInfo.M_and_As, tblAttyInfo.Oil_and_Gas, tblAttyInfo.Prof_Corps, tblAttyInfo.Real_Estate, tblAttyInfo.Securities, tblAttyInfo.Syndctn, tblAttyInfo.Takeovers, tblAttyInfo.Tax, tblAttyInfo.T_and_E, tblAttyInfo.Workers_Comp FROM tblAttyInfo WHERE (((tblAttyInfo." & strsort & "))=1) ORDER BY " & strsort & " , Attorney_Name;"<BR><BR><BR><BR><BR>set rstemp=objConn.execute(mysql)<BR><BR>&#039howmanyf ields=rstemp.fields.count -1<BR><BR>response.write "&#060;B&#062;" & strsort & " LIST &#060;/b&#062;"<BR><BR>If not rstemp.eof then<BR> response.write "&#060;table border=1 cellpadding=4&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;ATTY_ID&#060;/th&#062;"<BR> response.write "&#060;th&#062;ATTORNEY_NAME&#060;/th&#062;"<BR> response.write "&#060;td rowspan=&#039 30&#039 valign=&#039top&#039&#062;&#060;table&#062;&#060;t r&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=ADMINISTRATIVE&#039 &#062;ADMINISTRATIVE&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=ANTITRUST&#039&#062 ;ANTITRUST&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=BANKRUPTCY&#039&#06 2;BANKRUPTCY&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=CLOSELY_HELD_BUSINE SS&#039&#062;CLOSELY_HELD_BUSINESS&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=COMM_TRANS&#039&#06 2;COMM_TRANS&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=CONDOS&#039&#062;CO NDOS&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=CORP&#039&#062;CORP &#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=CRIMINAL&#039&#062; CRIMINAL&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=DOM_RELTNS&#039&#06 2;DOM_RELTNS&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=EMP_BEN&#039&#062;E MP_BEN&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=ENVIRONMENTAL&#039& #062;ENVIRONMENTAL&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=FIN_INST&#039&#062; FIN_INST&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=FRANCHISE&#039&#062 ;FRANCHISE&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=HEALTH_LAW&#039&#06 2;HEALTH_LAW&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=IMMIGRATION&#039&#0 62;IMMIGRATION&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=INSURANCE&#039&#062 ;INSURANCE&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write " &#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=INTL_BUS&#039&#062; INTL_BUS&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=INTEL_PROP&#039&#06 2;INTEL_PROP&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write " &#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=LABOR&#039&#062;LAB OR&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=LIT&#039&#062;LIT&# 060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write " &#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=M_and_As&#039&#062; M_and_As&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write " &#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=Oil_and_Gas&#039&#0 62;Oil_and_Gas&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=PROF_CORPS&#039&#06 2;PROF_CORPS&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write " &#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=REAL_ESTATE&#039&#0 62;REAL_ESTATE&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=SECURITIES&#039&#06 2;SECURITIES&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=SYNDCTN&#039&#062;S YNDCTN&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write "&#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=TAKEOVERS&#039&#062 ;TAKEOVERS&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR>response.write " &#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=TAX&#039&#062;TAX&# 060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write " &#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=T_and_E&#039&#062;T _and_E&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;"<BR> response.write " &#060;tr&#062;&#060;th&#062;&#060;a href=&#039attydbsort1.asp?sort=WORKERS_COMP&#039&# 062;WORKERS_COMP&#060;/a&#062;&#060;/th&#062;&#060;/tr&#062;&#060;/table&#062;&#060;/td&#062;"<BR> response.write " &#060;/tr&#062;"<BR><BR><BR><BR> Do While Not rstemp.EOF<BR> <BR><BR> <BR>strATTY_ID = rstemp("ATTY_ID")<BR>strATTORNEY_NAME = rstemp("ATTORNEY_NAME")<BR><BR><BR><BR><BR><BR><BR ><BR><BR><BR>response.write "&#060;tr&#062;&#060;td&#062;" & strATTY_ID & "&#060;/td&#062;&#060;td&#062;&#060;a href=&#039attydbatty.asp?atty=" & strATTY_ID & "&#039&#062;" & strATTORNEY_NAME & "&#060;/a&#062;&#060;/td&#062;&#060;/tr&#062;"<BR> rstemp.movenext<BR> <BR> Loop<BR>Response.write "&#060;/table&#062;"<BR> <BR><BR><BR><BR><BR>End if<BR><BR><BR> rstemp.close<BR> <BR><BR>Set rstemp = nothing<BR>objConn.close<BR>Set objConn = nothing<BR>response.write "&#060;/center&#062;"<BR>%&#062;<BR><BR>Of course there is a way to do this more dynamically, but my database field names are not going to change so I layed it out the way I wanted to be.<BR><BR>I hope this helps.<BR><BR>Respectfully,<BR><BR>Jason<BR>webmas ter@wnj.com

  3. #3
    someone Guest

    Default RE: Sortable table (Jason)

    Jason,<BR><BR>Thanks for the help. My columns are now sorting however, my Expense_Date and Amount columns are NOT sorting the way I would like. I want most recent date first and most_expensive Amount first. The opposite is happening. How do I rectify this matter???

Posting Permissions

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