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

passing form info over hrefs 1

Status
Not open for further replies.

nohandlesleft254

IS-IT--Management
Apr 19, 2006
58
GB
Hi,

If i was to ask what the most efficient method for keeping form results within a page long after the form has been submitted would most people tell me the same thing?

I have a search form with 8 fields. Once the form is submitted the user can then use a pages function, or column sort function to arrange their results; what is the best way of me keeping the form info each time the user uses one of these features?

(i am currently adding all fields to a URLparams var at the top of the page and have the ?#URLparams# on each href)
 
There's probably a million decent ways to do that, but I have achieved relative success using the method you described of appending a variable and then putting it after the ? on the hrefs of column headers. But if the search criteria is ugly, I don't particularly like seeing it on the URL,

Another way to do it is to make a form above the table (open and close) that contains only hidden fields that contain all the variables/values you want to pass. Then your columnheaders your href you do something like this:

Code:
<a href="page.cfm?sort=header" onclick="document.form1.action=this.href;document.form1.submit();return false;">header text</a>

The onclick has 3 statements:
1. change the action="" in document.form1 to be the same as the contents of the preceeding href.
2. submit the form by name.
3. return false in the onclick of an href will prevent the browser from executing the actual href.. IE, you can both submit the form AND click the href.. Some browsers will submit the form without the return false, but others will follow the href unless the form submits VERY quickly.
 
Thanks jmille34! thats perfect - the code i settled on is below.


<!--//
function submitsortcolumn(URL)
{
document.AdvancedSearch.action=URL;
document.AdvancedSearch.submit();
return false;
}
//-->

onClick="submitsortcolumn('YourQuotes.cfm?CurTab=#CurTab#&sort=#IIF(sort is 9, '10', '9')#');
 
Yup, perfecto.. I've implemented this a million different ways, and the javascript is very straight forward and clean, as are the hrefs. I especially love that the hrefs are clean, so when the user mouses over one of the headers, a nice tight url appears on the status bar, but then when they click it, all the form fields go with it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top