Solved

ColdFusion How can I display the users search criteria after hitting the search button?

Posted on 2014-04-11
5
240 Views
Last Modified: 2014-04-12
I have a binded drop down - Select "Property" and "Projects" will list associated Projects with the Property.

The problem is above the query results displaying what the user queried - If the user clicks on a Property the Projects automatically display, and if the user does not click on a Project:
You searched for: Property = Georgetown Estates  Project/s = All

How can I display the Projects (associated with the Property) without the user clicking on them:
You searched for: Property = Georgetown Estates  Project/s = New Foundation, New Roof

Code displaying what the user queried:
You searched for: Property = #discipline1#  Project/s = #discipline2#

Binded drop down code:

<cfselect name="discipline4" style=width:150px;height:92px; title="Press and hold Ctrl key to select multiple projects" multiple>
    <option value="ALL">ALL</option>
    <cfoutput query="DropDown4">
      <option value="#DropDown4.projectnumber#">#DropDown4.projectnumber#</option>
    </cfoutput>
    <cfselect name="discipline4"
                bind="cfc:MyComponent.getProjects( {discipline1} )"
                value="projectnumber"
                display="projectnumber"/> 

Open in new window

0
Comment
Question by:DJPr0
  • 3
  • 2
5 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 39995435
First, the code is a bit confusing since the field names don't match up with your descriptions. To avoid confusion, for now let's call them

<cfselect name="Property" multiple ....>
    <option value="ALL">ALL</option>
    <cfoutput query="DropDown4">
        <option .....</option>
    </cfoutput>
</cfselect>

<cfselect name="Project"
                bind="cfc:MyComponent.getProjects( {Property} )"
                value="projectnumber"
                display="projectnumber"/>


The problem is above the query results displaying what the user queried - If the user clicks on a Property the Projects automatically display, and if the user does not click on a Project:

You searched for: Property = Georgetown Estates Project/s = All

You're saying you already have code that displays the above? Can you post that code and any related cfc queries?
0
 

Author Comment

by:DJPr0
ID: 39995464
Basically I want to display what the Project Multi-select box displays in the query form when a Property is selected. (List Projects associated with Property selected)

Please note, I have a CFComponent which feeds the Project select box from the Property drop-down.

Code for: You searched for: Property = Georgetown Estates Project/s = All
             
 You searched for: Property = #discipline1#  Project/s = #discipline4#

Open in new window


Part of the query code:

<cfif discipline1 neq "ALL">
		AND Property = '#discipline1#' 
		</cfif>
<cfif discipline4 Is NOT "ALL">
	        AND projectnumber IN (#ListQualify(Form.discipline4,"'")#) 
			</cfif>

Open in new window

0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 39995495
You searched for: Property = #discipline1#  Project/s = #discipline4#

Ok so the reason it's displaying "All" is because that's the value of the FORM field.  

If you want it to display something different you either need to:

a)  Run the cfc query when the page loads

     <cfset obj = createObject("component", "MyComponent")>
     <cfset selectedProjects = obj.getProjects( FORM.ThePropertyField )>
     
Then use valueList to display the query results:
 
   ....
   You searched for: Property = #FORM.ThePropertyField#  
               Project/s = #ValueList(selectedProjects.projectnumber)#


OR

b) If you're automatically repopulating the "Project" list when the page loads, you could create another bind on that field. But that requires using a CFDIV or a CFINPUT, which might not fit with your layout.
0
 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 500 total points
ID: 39995551
> Run the cfc query when the page loads

... or if the "Project" form field can sometimes contain a list of projects, only run the query if the form field value is "ALL".

(Edit)  I'm heading out. It's been a long week.  I'll check back tomorrow.
0
 

Author Closing Comment

by:DJPr0
ID: 39996688
Worked great, thanks _agx_!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

831 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