Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...The level of expertise is awesome. The nature in which people respond is professional helpful and not the least condescending. I can't say that for most forums..."

Geography

Where in the world do Tek-Tips members come from?
maxCohen (Programmer)
9 Jul 12 17:08
I have a form where the user selects what department data they want to look at by checking off the areas they are interested in. The checkbox data is passed to the query as a list which is where I'm running into problems. Each department has its own set of data that will be output to a table on the results page. Right now the output is coming out with the whole department as a list and only one of the department's data showing up. How do I get each individual department's name and it corresponding data set to come out so it can be displayed?

Example:

<cffunction access="public" name="getInformation">
<!--- checks to see that there is a value for the department list --->
<cfif isDefined("form.department") is "True">
<cfquery name="getInfo" dataSource="departmentdata">
SELECT *
FROM DepartmentSet
WHERE department IN (<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#form.department#" list="yes" separator=",">) AND location = 'Gettysburg'
ORDER BY department ASC
</cfquery>
<cfelse>
<cfquery name="getInfo" dataSource="departmentdata">
SELECT *
FROM DepartmentSet
WHERE department = 'none'
</cfquery>
</cfif>

<cfreturn getInfo>
</cffunction>
Glowball (Programmer)
26 Jul 12 1:48
I'm not completely sure I understand what you mean. If you put this before your cfreturn tag are you getting the results you were expecting in all cases?

<cfdump var=#getInfo#><cfabort>

Also, if this is a function then the arguments you pass to it are in the ARGUMENTS scope. The page that calls something like getInformation("HR") would know about the FORM scope, but the getInformation() function won't know that scope. See http://livedocs.adobe.com/coldfusion/8/htmldocs/he... for more information about that. See if this works for you (I didn't test it because I don't have your data, but something along this line should work):

<cffunction access="public" name="getInformation">
<cfargument name="department" type="string" default="" />

<cfquery name="getInfo" dataSource="departmentdata">
SELECT *
FROM DepartmentSet
<cfif Len(Trim(ARGUMENTS.department))>
WHERE department IN (<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#ARGUMENTS.department#" list="yes" separator=",">) AND location = 'Gettysburg'
<cfelse>
WHERE department = 'none'
</cfif>
ORDER BY department ASC
</cfquery>

<cfreturn getInfo>
</cffunction>

<cfset myvar = getInformation()>
<cfdump var=#myvar#>

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close