?
Solved

ColdFusion How can I make my search page input criteria sticky?

Posted on 2014-03-09
6
Medium Priority
?
342 Views
Last Modified: 2014-03-13
I have a search page with dynamic drop downs and input boxes which populates on the same page as the results.

Problem: When the results are displayed the search box is automatically reset. How can I save the last input criteria to display in the search box with the results?

Users would click on a "Clear" button to clear all the input fields.
0
Comment
Question by:DJPr0
  • 3
  • 3
6 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 39916314
Depends on how you're submitting the form: ajax or regular page submit. If it's a regular form submit just use the URL/FORM fields to populate to input field "value".

Note: If you're using method=post, change the scope from URL to FORM

           <!--- set defaults so the fields always exist --->
           <cfparam name="URL.input1" default="">
           <cfparam name="URL.input2" default="">
           ....
           <!--- use values to populate fields --->
           <form method="get" ...>
             <cfoutput>
              <input type="text" name="input1" value="#URL.input1#">
              <input type="text" name="input2" value="#URL.input2#">
             </cfoutput>
           </form>
0
 

Author Comment

by:DJPr0
ID: 39916406
Thanks for your reply _agx_

I'm using method=post

Also my "Clear" button stopped working to refresh the fields.

How can I apply to binded and query dropdowns:

<select name="discipline3" style=width:172px;>
        <option value="ALL">ALL</option>
         <cfoutput query="DropDown2">
           <option value="#DropDown2.vendor#">#DropDown2.vendor#</option>
         </cfoutput>
     </select></td>
      <td>Project</td>

<td><cfselect name="discipline4" style=width:154px; title="Press and hold Ctrl key to select multiple projects" multiple>
      <option value="ALL">ALL</option>
      <cfoutput query="DropDown4">
          <option value="#DropDown4.ProjNum#">#DropDown4.ProjNum#</option>
        </cfoutput>
        <cfselect name="discipline4"
                bind="cfc:MyComponent3.getProjects( {discipline1} )"
                value="ProjNum"
                display="ProjNum"
                multiple="Yes"/>
                  </cfselect></td>
0
 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 2000 total points
ID: 39916533
> How can I apply to binded and query dropdowns:

With non-bind selects, just compare the values within the query loop:

        <cfoutput query="DropDown2">
              <option value="#DropDown2.vendor#"
                      <cfif DropDown2.vendor eq FORM.discipline3>selected</cfif>
                > #DropDown2.vendor#</option>
         </cfoutput>        

For bound selects in CF9+ use the "selected" attribute .

       <cfselect name="discipline4"  selected="#FORM.discipline4#" .... >

 (Edit) If you're using an earlier version than CF9, you'll have to do the bind part manually. Just do a search on "cfselect bind selected" and you'll find a bunch of examples.
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

Author Comment

by:DJPr0
ID: 39925176
Works good _agx_, except for the multiple selection - if one is selected it works fine.
If two selections are made, it defaults to "ALL".

Multiselect code:

<cfselect name="discipline4" style=width:154px; title="Press and hold Ctrl key to select multiple projects" multiple>
      <option value="ALL">ALL</option>
      <cfoutput query="DropDown4">  
          <option value="#DropDown4.ProjNum#"          
           <cfif DropDown4.ProjNum eq FORM.discipline4>selected</cfif>
           >  #DropDown4.ProjNum#</option>          
        </cfoutput>
        <cfselect name="discipline4" selected="#FORM.discipline4#"
                bind="cfc:MyComponent3.getProjects( {discipline1} )"
                value="ProjNum"
                display="ProjNum"
                multiple="Yes"/>
                  </cfselect></td>
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 total points
ID: 39925188
Oh, if the list supports multiple you'll need to use list functions instead of EQ:

<cfif listFindNoCase(FORM.discipline4, DropDown4.ProjNum)>selected</cfif>

Not sure about binds.. it *should* automatically work if you use the "selected" attribute in CF9+. That is assuming Adobe programmed it correctly ...
0
 

Author Closing Comment

by:DJPr0
ID: 39926715
Thanks _agx_!!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question