Link to home
Start Free TrialLog in
Avatar of D J
D JFlag for United States of America

asked on

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

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.
Avatar of _agx_
_agx_
Flag of United States of America image

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>
Avatar of D J

ASKER

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>
SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of D J

ASKER

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>
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of D J

ASKER

Thanks _agx_!!