0
Dynamic checkboxes
Participant
,
/t5/coldfusion-discussions/dynamic-checkboxes/td-p/399267
Apr 09, 2008
Apr 09, 2008
Copy link to clipboard
Copied
I want to dynamically generate checkboxes from a query :
<cfloop query="qryGet_Error">
<cfoutput>
<cfinput type="checkbox" name="error_id" value="#qryGet_Error.error_id#">#qryGet_Error.error#<br>
</cfoutput>
</cfloop>
In the action page, I would have something like this, but how would I setup the select query, based on each checkbox value ?
<cfif isDefined("form.error_id")>
<cfloop list="#form.error_id#" index="error_id_value">
<cfquery name="qry" datasource="datasource">
For example, the query would have to be select if error_id = '1' or error_id = '3' or error_id = '8', etc., based on which checkboxes were selected.
I do not know how to set this up.
<cfelse>
no checkboxes were selected, display message
</cfif>
Thanks
<cfloop query="qryGet_Error">
<cfoutput>
<cfinput type="checkbox" name="error_id" value="#qryGet_Error.error_id#">#qryGet_Error.error#<br>
</cfoutput>
</cfloop>
In the action page, I would have something like this, but how would I setup the select query, based on each checkbox value ?
<cfif isDefined("form.error_id")>
<cfloop list="#form.error_id#" index="error_id_value">
<cfquery name="qry" datasource="datasource">
For example, the query would have to be select if error_id = '1' or error_id = '3' or error_id = '8', etc., based on which checkboxes were selected.
I do not know how to set this up.
<cfelse>
no checkboxes were selected, display message
</cfif>
Thanks
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/dynamic-checkboxes/m-p/399268#M35937
Apr 09, 2008
Apr 09, 2008
Copy link to clipboard
Copied
where yourfield in (some list)
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
LATEST
/t5/coldfusion-discussions/dynamic-checkboxes/m-p/399269#M35938
Apr 09, 2008
Apr 09, 2008
Copy link to clipboard
Copied
to clarify Dan's post a bit more:
to select multiple records at once you use WHERE columnname IN
(comma-delimited list of values) in your query
thus, you do not need the cfloop at all, since the value of
form.error_id is already a comma-delimited list.
your query will look something like:
SELECT ...
FROM ...
WHERE error_id IN (<cfqueryparam cfsqltype="cf_sql_integer" list="yes"
value="#form.error_id#">)
assuming error_id is an INT/NUMBER data type. if it is of text-based
data type, then change cf_sql_integer to cf_sql_varchar.
hth
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
to select multiple records at once you use WHERE columnname IN
(comma-delimited list of values) in your query
thus, you do not need the cfloop at all, since the value of
form.error_id is already a comma-delimited list.
your query will look something like:
SELECT ...
FROM ...
WHERE error_id IN (<cfqueryparam cfsqltype="cf_sql_integer" list="yes"
value="#form.error_id#">)
assuming error_id is an INT/NUMBER data type. if it is of text-based
data type, then change cf_sql_integer to cf_sql_varchar.
hth
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

