Forums: How to display advanced search parameters on the List page - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to display advanced search parameters on the List page

#1 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 8096
  • Joined: 03-February 03

Posted 30 June 2007 - 06:52 PM

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 snippet option on the Visual Editor tab) instead of Listonload event.
Best regards,
Sergey Kornilov
0

#2 User is offline   paulyap 

  • Member
  • PipPip
  • Group: Members
  • Posts: 18
  • Joined: 18-April 08
  • Gender:Male
  • Location:SF Bay Area

Posted 26 August 2008 - 01:46 PM

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

-------------------------

View Postadmin, on Jun 30 2007, 10:52 AM, said:

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

0

#3 User is offline   fenhow 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 15-May 09

Posted 15 May 2009 - 06:51 PM

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.
0

#4 User is offline   Jane 

  • Advanced Member
  • PipPipPip
  • Group: Admin
  • Posts: 7121
  • Joined: 13-June 06
  • Gender:Female

Posted 25 May 2009 - 12:30 PM

ASPRunnerPro 6.1

Quote

dim start1,end1
strSearch=""


if REQUEST("a")="advsearch" then

doAssignment asearchfield,postvalue("asearchfield")

if not asp_is_array(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("value_1" & 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

best regards,
Jane Endaltseva
e-mail: support@xlinesoft.com
0

#5 User is offline   Vic 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 08-February 10

Posted 08 February 2010 - 11:30 PM

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'
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users