Solved

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

Posted on 2014-04-11
5
261 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
[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
  • 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
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 …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

710 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