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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to sort search query results and keep the results same

Status
Not open for further replies.

olchiik

Programmer
May 7, 2009
33
0
0
US
Hello,

I need to be able to sort results by clicking on column header. I know how to do it, but the problem is it sorts all the results. I have a "search by" form. So the results I get come from that search form, depending what user is looking for. Then in the results I need to include sort by clicking on column header, but each time I click on header...it displays all the results (including those user aren't interested). So it runs query again, but since it doesn't run from the form, whatever user entered in the form, is not defined anymore. Does anybody knows way around it?

Thank you!
 
So it runs query again, but since it doesn't run from the form, whatever user entered in the form, is not defined anymore. Does anybody knows way around it?

Modify the code to pass along the search criteria whenever the header is clicked.

One option is to include the "search by" value in the column header url:

<a href="thisPage.cfm?sortBy=something&searchBy=#searchByValue#">Sort By something</a>

Another option is to use a form and store the values in hidden fields. If you use method="get" the hidden field values will be passed as url parameters.

----------------------------------
 
CfSearching thank you for your help. I will try to do it
 
I have used form with hidden fields and I put method "get" and it didn't do anything. It still shows all results after I click on column name :-(
 
Oh..no it's not. How do I make it to sumit the form?
 
Hi cfSearching.

I am kind of lost here. I know how to submit form using link, but I don't know how to submit and sort using same link.
There is more than one column I need to be able to sort by. I was trying it, but it still displays all records and doesn't sort:-(
 
I got to the point when it displays only searched records, but sort gives me JavaScript error.
<a href="javascript:document.getElementById('passinfo').submit();&sort=feedbackregard">

I guess I cannot do it like this... but how do I add sort?
 
cfSearching..I got it...
thank you for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top