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

Form field with comma delimited value list to cfc

Guest
Sep 21, 2006 Sep 21, 2006

Copy link to clipboard

Copied

I have a form that passes a field to an action page with a comma delimited value.

For instance the field name is: Program_ID

value for program_ID is: 31, 32

I am able to treat this variable as a list and check its length, and loop over the list prior to passing it to a cfc using the attached code:

When I try and pass the variable as a string to a cfc and invoke a query, cf no longer recognizes my var as a list.

Therefore the code attached does not function...

Is there a specific var type that will pass through as a list and allow me to run the code block attached?

thanks

Craig
TOPICS
Advanced techniques

Views

333

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

Deleted User
Sep 22, 2006 Sep 22, 2006
Ok answered my own question.. Here is the answer for those who are interested...

initialize var for cfc in cfinvoke statement
<cfinvokeargument name="Program_ID" value="#Form.Program_ID#">

pass argument to cfc as a string
<cfargument name="Program_ID" type="string" required="true">

use listqualify to parse list in cfc and set new var
<cfset selectedProgramID = ListQualify(Program_ID,"'",",","CHAR")>

use the new var in the following statement in sql code:
((Program_ID) IN (#PreserveSingleQuot...

Votes

Translate

Translate
Guest
Sep 22, 2006 Sep 22, 2006

Copy link to clipboard

Copied

LATEST
Ok answered my own question.. Here is the answer for those who are interested...

initialize var for cfc in cfinvoke statement
<cfinvokeargument name="Program_ID" value="#Form.Program_ID#">

pass argument to cfc as a string
<cfargument name="Program_ID" type="string" required="true">

use listqualify to parse list in cfc and set new var
<cfset selectedProgramID = ListQualify(Program_ID,"'",",","CHAR")>

use the new var in the following statement in sql code:
((Program_ID) IN (#PreserveSingleQuotes(selectedProgramID)#))

The following code handles a form field with a single value or a comma delimited value.

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