5 Replies Latest reply on Dec 29, 2006 11:51 PM by BKBK

    Loop in a CFC

    weblover
      Hi,

      am trying to write a query in a Function where i need to return results for a search criteria from a form.

      search has 3 drop down lists which has 3 text boxes assigned to retrieve results based on the selection and entering text.

      let's say first drop down has a list value of "Customer name" and search value is "John" ..

      Query has to retrieve. results where " Customer name" is "John"

      like wise i've 3 Dropdown boxes .. which has same list values (i.e., customer name, customer city, country etc.,)
      and 3 text boxes, and 2 Operator boxes ("and", "Or) .



      Pls.see the Screen Shot here



      and i want to retrieve results by looping those 3 list boxes in my Query and sametime using the textbox values and operator.

      CFFUCNTION doesn't allow type "struct" in arguments if the return type is "query"


      here is the code


      <cffunction name="getList" output="true" returntype="query" >


      <cfargument name="searchstring" type="any" required="no" default="">

      <cfargument name="searchvalue" type="any" required="no" default="">

      <cfargument name="operator" type="any" required="no" default="">

      <cfquery name="get_values" datasource="#application.dsn#">
      SELECT * FROM TABLE
      WHERE 0=0

      AND
      <CFLOOP INDEX="i" list="#arguments.searchstring# delimiters=",">

      -- here i need to get the corresponding "textbox" and "Operator" values --

      for ex: AND (operator) CUSTOMER_NAME LIKE %JOHN% (textbox value)

      </cfloop>

      </cfquery>
      </cffunction>


      Thanks in advance
      Weblover.