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

Dynamic checkboxes

Participant ,
Apr 09, 2008 Apr 09, 2008
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
229
Translate
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
LEGEND ,
Apr 09, 2008 Apr 09, 2008
where yourfield in (some list)
Translate
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
LEGEND ,
Apr 09, 2008 Apr 09, 2008
LATEST
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/
Translate
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