Highlighted

Get form values

Community Beginner ,
Sep 01, 2015

Copy link to clipboard

Copied

I have a form that is passing values like  this.

GETL639NAVY 1649

GETL639ORANGE 1653

GETL639PURPLE 0

GETL794BLACK 0

GETL794NAVY 0

GETL794SAHARA 0

GETL794WHITE 0

GETLST660BLUEWAKE 0

When its not 0 I would like to get

that specific record from a query

select * from table

where ID = '#number#'

Adobe Community Professional
Correct answer by BKBK | Adobe Community Professional

<cfif isDefined("form.GETL639NAVY")>

  <!--- List of all form fields --->

  <cfset formFieldList = form.fieldnames>

  <cfloop list="#formFieldList#" index="formField">

  <cfif left(formfield,3) is "get" and isNumeric(form[formfield]) and form[formfield] is not 0><!---  Field-name begins with "get" and field value is a number other than 0--->

       <cfquery name="#formfield#Query"><!---Distinguish dynamically between the queries --->

        SELECT *

         FROM TBL

         WHERE ID = <cfqueryparam value="#form[formfield]#" CFSQLType='CF_SQL_INTEGER'>

       </cfquery>

  </cfif>

  </cfloop>

</cfif>

Views

192

Likes

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

Get form values

Community Beginner ,
Sep 01, 2015

Copy link to clipboard

Copied

I have a form that is passing values like  this.

GETL639NAVY 1649

GETL639ORANGE 1653

GETL639PURPLE 0

GETL794BLACK 0

GETL794NAVY 0

GETL794SAHARA 0

GETL794WHITE 0

GETLST660BLUEWAKE 0

When its not 0 I would like to get

that specific record from a query

select * from table

where ID = '#number#'

Adobe Community Professional
Correct answer by BKBK | Adobe Community Professional

<cfif isDefined("form.GETL639NAVY")>

  <!--- List of all form fields --->

  <cfset formFieldList = form.fieldnames>

  <cfloop list="#formFieldList#" index="formField">

  <cfif left(formfield,3) is "get" and isNumeric(form[formfield]) and form[formfield] is not 0><!---  Field-name begins with "get" and field value is a number other than 0--->

       <cfquery name="#formfield#Query"><!---Distinguish dynamically between the queries --->

        SELECT *

         FROM TBL

         WHERE ID = <cfqueryparam value="#form[formfield]#" CFSQLType='CF_SQL_INTEGER'>

       </cfquery>

  </cfif>

  </cfloop>

</cfif>

Views

193

Likes

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
Sep 01, 2015 0
Advocate ,
Sep 01, 2015

Copy link to clipboard

Copied

Do you mean something like this?:

<cfif form.GETL639NAVY neq 0>

<cfquery name="theQuery">

  SELECT *

  FROM table

  WHERE ID = <cfqueryparam value="#form.GETL639NAVY#" CFSQLType='CF_SQL_INTEGER'>

</cfquery>

</cfif>

Likes

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
Reply
Loading...
Sep 01, 2015 0
Community Beginner ,
Sep 01, 2015

Copy link to clipboard

Copied

no sorry.

that would be for that specific variable.

But for all variables

'GET....' if the variable is not equal to 0

then i would like it to find the record in the table which is the ID

Likes

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
Reply
Loading...
Sep 01, 2015 0
Adobe Community Professional ,
Sep 03, 2015

Copy link to clipboard

Copied

<cfif isDefined("form.GETL639NAVY")>

  <!--- List of all form fields --->

  <cfset formFieldList = form.fieldnames>

  <cfloop list="#formFieldList#" index="formField">

  <cfif left(formfield,3) is "get" and isNumeric(form[formfield]) and form[formfield] is not 0><!---  Field-name begins with "get" and field value is a number other than 0--->

       <cfquery name="#formfield#Query"><!---Distinguish dynamically between the queries --->

        SELECT *

         FROM TBL

         WHERE ID = <cfqueryparam value="#form[formfield]#" CFSQLType='CF_SQL_INTEGER'>

       </cfquery>

  </cfif>

  </cfloop>

</cfif>

Likes

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
Reply
Loading...
Sep 03, 2015 0