Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Combining two lists of values so I can loop through them as one list

Posted on 2003-03-26
Medium Priority
Last Modified: 2013-12-24
I have created a form that displays a record set using the cfgrid component.  Right now, users are able to filter the list based on a single condition. For example, they can see all items with a 'Developer' value of 'Bob'. The values for Filterby (Developer) and Filtervalue (Bob) are being sent as URL variables. However, now I'm trying to allow the filter to have multiple conditions. For example, Developer='Bob' AND 'open_closed=Open'. Hence, the value for Filterby would be 'Developer, open_closed' and the value for Filtervalue would be 'Bob, Open'.  How can I combine these two lists into one structure so that I can loop through the values and set each condition in a query that I'm building on the fly based on the url variables?  Thanks in advance for your help...I'll copy the pertinent code below:

This is the URL with the variables:


This is the query I'm trying to build:

<CFQUERY DBTYPE="query" name="TrackerList" cachedwithin="#CreateTimeSpan(0,0,0,-1)#">
FROM <cfif NOT IsDefined("history")>TrackerCache<cfelse>TrackerHistory</cfif>
<cfloop list='FilterList'>
     <CFIF (ParameterExists(Filterby) IS "Yes")>
          <cfif (Filterby IS NOT 'blank') AND (Filterby IS NOT 'Title') AND (Filterby IS NOT 'Manager') AND (Filterby IS NOT 'QA') AND (Filtervalue IS NOT 'isnull')>
               AND #Filterby# = '#filtervalue#'
          <cfelseif Filtervalue IS 'isnull'>          
               AND (#Filterby# IS NULL)
          <cfelseif Filterby IS 'Title'>
               AND #Filterby# LIKE '%#filtervalue#%'
          <cfelseif Filterby IS 'QA'>
               AND Status = 'Ready for Review' AND Reviewer = '#session.userid#'
          <cfelseif (Filterby IS 'manager') AND (session.roleID Contains 'DevManager')>
               AND Status = 'New' AND Product IN (#PreserveSingleQuotes(prodsmanaged)#)
     ORDER BY ItemNumber
Question by:sloap

Accepted Solution

TallerMike earned 500 total points
ID: 8211052
Try something like this instead:


url.filter will return this:


Then you'll want to loop through url.filter like so:

<cfloop list="#url.filter#" index="filterNameValue">
  <cfset filterName = GetToken(filterNameValue,1,"~">
  <cfset filterValue = GetToken(filterNameValue,2,"~">

Author Comment

ID: 8211155
Thanks TallerMike...that was exactly what I was looking for and it worked fabulously...

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

578 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