This topic is locked

How to Filter by Column Headings

10/5/2007 2:30:18 PM
ASPRunnerPro General questions
emoss author

Can the column headings on the list page be changed to dropdown boxes that contain all unique values in the associated column.

It would be much more convenient to filter a list this way than with the single search box provided on the page...
Great App!!! Thank you!
EBM

Sergey Kornilov admin 10/8/2007

You can use Insert ASP code snippet function for this purpose.
Here is the sample code:

dim rs

FieldName = "Make"

set rs = server.createobject("ADODB.Recordset")

rs.open "Select " & FieldName & " from " & strTableName, dbConnection
Response.Write "<script>" & vbcrlf

Response.Write "function gopage(theLink) { " & vbcrlf

Response.Write "if (document.frmAdmin.theLink.value != '') {" & vbcrlf

Response.Write "location.href = 'cars_list.asp?a=search&value=1&SearchFor=' + document.frmAdmin.theLink.value + '&SearchOption=Equals&SearchField=" & FieldName & "'; } }" & vbcrlf

Response.Write "</script>" & vbcrlf
Response.Write "<select name='theLink' onchange='gopage(this)'>" & vbcrlf

Response.Write "<option selected value=''></option>" & vbcrlf


while not rs.eof

Response.Write "<option value='" & rs(FieldName)& "'>" & rs(FieldName)& "</option>" & vbcrlf

rs.MoveNext

wend

Response.Write "</select>"