• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Loop in a CFC

New Here ,
Dec 27, 2006 Dec 27, 2006

Copy link to clipboard

Copied

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.
TOPICS
Advanced techniques

Views

653

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

New Here , Dec 29, 2006 Dec 29, 2006
Hi BKBK,

thanks a bunch for your help.. it worked.... i just replaced my code with yours with little modifications..and works perfect..

thanks again.
Weblover.

Votes

Translate

Translate
LEGEND ,
Dec 27, 2006 Dec 27, 2006

Copy link to clipboard

Copied

It might be simpler to get your query working in a normal template before adding the complication of a cfc. Try to simplify as much as you can. Your post leads me to believe you are overthinking your problem.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 27, 2006 Dec 27, 2006

Copy link to clipboard

Copied

Don't know if it means anything, but you forgot to terminate your list attribute with a quotation mark. Also, is arguments.searchstring a list, or a struct? If it's a struct then it belongs in the collection attribute instead of list, and requires the item attribute instead of index.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 27, 2006 Dec 27, 2006

Copy link to clipboard

Copied

I hope this points you in the right direction

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 29, 2006 Dec 29, 2006

Copy link to clipboard

Copied

Hi BKBK,

thanks a bunch for your help.. it worked.... i just replaced my code with yours with little modifications..and works perfect..

thanks again.
Weblover.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 29, 2006 Dec 29, 2006

Copy link to clipboard

Copied

LATEST
!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation