Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search next and previous

Status
Not open for further replies.

Gill1978

Programmer
Joined
Jun 12, 2001
Messages
277
Location
GB
Hi!
I searched the forum and found an example on how to show only say 5 results of a query per page. This works fine, however, when i try and see the next page I get the following error:

An error occurred while evaluating the expression:


#searchCriteria#



Error near line 47, column 12.
--------------------------------------------------------------------------------

Error resolving parameter SEARCHCRITERIA


ColdFusion was unable to determine the value of the parameter. This problem is very likely due to the fact that either:

You have misspelled the parameter name, or
You have not specified a QUERY attribute for a CFOUTPUT, CFMAIL, or CFTABLE tag.


The error occurred while processing an element with a general identifier of (#searchCriteria#)

SearchCriteria is the name of a checkbox the user selects on page which the user sets the search criteria (USM_Search_Scree.cfm).

Can anyone help?
This is the cf code:
</cfoutput>
<table border=&quot;0&quot;>
<tr>
<td align=&quot;center&quot; valign=&quot;middle&quot;> </td>
<td>
<!--- If Previous is true, display the previous link. --->
<cfif previous>
<cfoutput>
<a href =&quot;USM_Results_Screen.cfm?StartRow=#PreviousStart#&PageNum=#DecrementValue(PageNum)#&quot;> « Previous</a>
</cfoutput>
<cfelse>

</cfif>
</td>
<cfloop from = &quot;1&quot; to = &quot;#NumPages#&quot; index = &quot;ThisPage&quot;>
<cfoutput>
<cfif thispage is pagenum>
<td><b>[#ThisPage#]</b></td>
<cfelse>
<cfset pagenumstart = (((thispage - 1) * oneachpage) + 1)>
<td>
<a href =&quot;USM_Results_Screen.cfm?StartRow=#PageNumStart#&PageNum=#ThisPage#&quot;> #ThisPage#</a></td>
</cfif>
</cfoutput>
</cfloop>
<td>
<!--- If Next is true, display the previous link. --->
<cfif next>
<cfoutput>
<a href =&quot;USM_Results_Screen.cfm?StartRow=#NextStart#&PageNum=#IncrementValue(PageNum)#&quot;> Next »</a>
</cfoutput>
<cfelse>

</cfif>
</td>
</tr>
</table>



Thanks

Julie
 
it looks like its running the query again and loses the value of SearchCriteria, is there any way of not re-running the query?
 
Use your links to pass your search criteria as a URL variable (as well as any other variables you need to run your query) along with PageNum, NextStart, etc. I'm sure you can avoid running the search more than once, caching it, maybe? But I'm not sure how to do that. Someone else care to jump in on that? Calista :-X
Jedi Knight,
Champion of the Force
 
I think all you need to do is add to the next and previous links this snippet of code:

&searchcriteria=#urlencodedformat(searchcriteria)#

The urlencodedformat is necessary to substitute %20 in place of any spaces that may be in your search criteria variable.

Hope this helps!

Roger
 
Thanks for the quick response, iv'e passed the search variables through the URL!!
Thanks again!

Julie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top