This topic is locked

How to display advanced search parameters on the List page

6/30/2007 2:52:27 PM
ASPRunnerPro Tips and tricks
admin

ASPRunnerPro 5.2

Here is the sample code. Paste it into ListOnLoad event and enjoy.

It could use some formatting like highlighting search phrase or field names. Also it doesn't add AND or OR between search parameters if you search for multiple criteria.

strSearch=""

if REQUEST("a")="advsearch" then
asearchfield = postvalue("asearchfield[]")

if not isarray(asearchfield) then

dim t

t=asearchfield

redim asearchfield(1)

asearchfield(0)=t

end if

for field=0 to ubound(asearchfield)

gfield=asearchfield(field)

asopt=postvalue("asearchopt_" & GoodFieldName(asearchfield(field)))

value1=postvalue("value_" & GoodFieldName(asearchfield(field)))

if value1="" then value1=postvalue("value_" & GoodFieldName(asearchfield(field)) & "[]")

ttype=postvalue("type_" & GoodFieldName(asearchfield(field)))

value2=postvalue("value1_" & GoodFieldName(asearchfield(field)))

if value2="" then value2=postvalue("value_1" & GoodFieldName(asearchfield(field)) & "[]")

nnot=postvalue("not_" & GoodFieldName(asearchfield(field)))

if nnot="on" then nnot = "not" else nnot="" end if
if not SafeIsEmpty(value1) or asopt="Empty" then

strSearch = strSearch & " " & ttype & " "

strSearch = strSearch & gfield & " " & nnot & " " & asopt & " "

if not isArray(value1) then

strSearch = strSearch & value1

else

strSearch = strSearch & combinevalues(value1)

end if

if not SafeIsEmpty(value2) then strSearch = strSearch & " and " & value2

end if

next
end if
if strSearch<>"" then _

response.write "Your search was for " & strSearch


ASPRunnerPro 6.0

Use custom event (Insert ASP code snippetoption on the Visual Editor tab) instead of ListOnLoad event.

P
paulyap2k 8/26/2008

Hi Sergey,
Which are the below fields needs to be changed to actual field name ?

I did a cut and paste which did not work (nothing change on the list page) so the above questions. Not sure its its the reason it does not work.
Are there anything else i need to observe to make this work ?, I am not a programmer.
Cheers,

Paul
-------------------------

Here is the sample code. Paste it into ListOnLoad event and enjoy.

It could use some formatting like highlighting search phrase or field names. Also it doesn't add AND or OR between search parameters if you search for multiple criteria.

strSearch=""

if REQUEST("a")="advsearch" then
asearchfield = postvalue("asearchfield[]")

if not isarray(asearchfield) then

dim t

t=asearchfield

redim asearchfield(1)

asearchfield(0)=t

end if

for field=0 to ubound(asearchfield)

gfield=asearchfield(field)

asopt=postvalue("asearchopt_" & GoodFieldName(asearchfield(field)))

value1=postvalue("value_" & GoodFieldName(asearchfield(field)))

if value1="" then value1=postvalue("value_" & GoodFieldName(asearchfield(field)) & "[]")

ttype=postvalue("type_" & GoodFieldName(asearchfield(field)))

value2=postvalue("value1_" & GoodFieldName(asearchfield(field)))

if value2="" then value2=postvalue("value_1" & GoodFieldName(asearchfield(field)) & "[]")

nnot=postvalue("not_" & GoodFieldName(asearchfield(field)))

if nnot="on" then nnot = "not" else nnot="" end if
if not SafeIsEmpty(value1) or asopt="Empty" then

strSearch = strSearch & " " & ttype & " "

strSearch = strSearch & gfield & " " & nnot & " " & asopt & " "

if not isArray(value1) then

strSearch = strSearch & value1

else

strSearch = strSearch & combinevalues(value1)

end if

if not SafeIsEmpty(value2) then strSearch = strSearch & " and " & value2

end if

next
end if
if strSearch<>"" then _

response.write "Your search was for " & strSearch
F
fenhow 5/15/2009

Hi, i tried this and it works however the reults are showing:
Your search was for date11 Date Between 05/04/2009 and 05/16/2009
Can you tell me where the date11 is coming from? also how can I change the font size of the result on the list page?
Thanks.

J
Jane 5/25/2009

ASPRunnerPro 6.1

dim start1,end1

strSearch=""
if REQUEST("a")="advsearch" then
doAssignment asearchfield,postvalue("asearchfield")
if not asp_isarray(asearchfield) then

set asearchfield = CreateDictionary1(0,asearchfield)

end if
GetCollectionBounds asearchfield,start1,end1
for field=start1 to end1
gfield=asearchfield(field)
asopt=postvalue("asearchopt
" & GoodFieldName(asearchfield(field)))
value1=postvalue("value" & GoodFieldName(asearchfield(field)))
if value1="" then value1=postvalue("value
" & GoodFieldName(asearchfield(field)) & "[]")
ttype=postvalue("type" & GoodFieldName(asearchfield(field)))
value2=postvalue("value1
" & GoodFieldName(asearchfield(field)))
if value2="" then value2=postvalue("value1" & GoodFieldName(asearchfield(field)) & "[]")
nnot=postvalue("not
" & GoodFieldName(asearchfield(field)))
if nnot="on" then nnot = "not" else nnot="" end if
if bValue(value1) or asopt="Empty" then
strSearch = strSearch & " " & ttype & " "
strSearch = strSearch & gfield & " " & nnot & " " & asopt & " "
if bValue(value1) then
strSearch = strSearch & value1
else
strSearch = strSearch & combinevalues(value1)
end if
if bValue(value2) then strSearch = strSearch & " and " & value2
end if
next
end if
if strSearch<>"" then _

response.write "Your search was for " & strSearch

V
vdrecchio 2/8/2010

Should this snippet also work for 6.2??
When I put this code in the Visual Editor "Insert Code Snippet" I get "Wrong Number of arguments or invalid property assignment: 's_XXXXXX_Snippet1'