?
Solved

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

Posted on 2014-03-09
6
Medium Priority
?
338 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

801 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