Skip to main content
Inspiring
October 15, 2008
Question

searching a Problem?

  • October 15, 2008
  • 2 replies
  • 299 views
I am doing a currently searching on my project where i pass all my values through GET method of form, they appear on the address bar as to whatever value is passwed, the results display properly.

I am using the navigation in results to display 10 recors and them moving like:

<a href="#CGI.SCRIPT_NAME#?personName=#url.personanme#&startRow=#startRowBack#">

when i move to next 10 rows and it automatically the last &startRow=#startRowBack# like &startRow=10 with the next paging and it generates error..

Is there a possbility how can i fix this issue/

if post method is fine can anyone guide me how i can do it?

if my approach is ok, then hardcoding the original values will make the string quite bigger.

So what shouldd be done here

please guide me?
Cheers
This topic has been closed for replies.

2 replies

Inspiring
October 15, 2008
Hi,

I would recommend against Abinidi's post. Do not use session variables!
That always causes problems if somebody goes directly to that page and the session variables don't contain the same values, as example for search engines or if somebody adds the URL to their favorites.

If you should use GET or depends on the situation:
1) As example with customer-facing product listings, where people should be able to link directly to that page, or add the URL to their favorites, or search engines should be able to display the filtered page in their search results, => Use GET
2) If the page is as example an internal administration page, and people should always be set to the empty default search screen => Use POST

cheers,
fober

For my applications I have built a function that I always use to update URL parameters, independent of any other parameters in the URL Query-String:


<!--- ==== USAGE SAMPLE ===================================== --->
<cfoutput>
<cfloop index="x" from="1" to="85" step="10">
<a href="#CGI.SCRIPT_NAME#?#URL_Update(CGI.QUERY_STRING,'startrow',x)#">Row:#x#-#x+9#</a> |
</cfloop>
</cfoutput>

<!--- ==== FUNCTION ========================================= --->
<cffunction name="URL_Update" returntype="string" output="No">
<cfargument name="url_attributes" required="Yes" type="string">
<cfargument name="item" required="Yes" type="string">
<cfargument name="value" required="Yes" type="string">

<cfif url_attributes is "">
<cfif value neq "">
<cfreturn "#item#=#value#">
<cfelse>
<cfreturn "">
</cfif>
</cfif>

<cfloop index= "temp" from= "1" to= "#listlen(url_attributes,'&')#">
<cfif find(ucase(item), ucase(listgetat(url_attributes, temp, '&'))) gt 0>
<cfif value neq "">
<cfreturn "#listsetat(url_attributes, temp, '#item#=#value#', '&')#">
<cfelse>
<cfreturn "#listdeleteat(url_attributes, temp, '&')#">
</cfif>
</cfif>
</cfloop>

<cfif value neq "">
<cfreturn "#listappend(url_attributes,'#item#=#value#','&')#">
<cfelse>
<cfreturn "#attributes#">
</cfif>
</cffunction>

Inspiring
October 15, 2008
I would not have your form variables pasted in the url. It gets complex after a few posts. I would do them as hidden form fields that you keep passing from form to form.

Or generate them as session variables and pass them as that.