Solved

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

Posted on 2014-04-11
5
226 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

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 …
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now