I'm sorry. I didnt mean to abandon you like that. I just couldnt get back
to the computer yesterday :-/
There are a couple ways that might work for you.
1) You can name all the checkboxes the same and when it is submitted, you'll
have a comma delimited list of the values selected. (This looks like what
you are going for)
<cfparam name="form.checkboxes"
default="#valuelist(getCheckboxes.checkboxid)#" />
<cfloop query="getCheckboxes">
<input type="checkbox" name="checkboxes" value="#checkboxid#<cfif
listfind(checkboxid, form.checkboxes)> checked />
</cfloop>
When you first hit this form... the checkboxes will ALL be selected since
the query returns every value that was used to make the checkboxes and those
values were also used to create the form variable.
Once you submit it, the form scope will take over and the values will be
checked against that. One down side is that if you deselect ALL boxes, this
method will select them ALL again.
2) You can build and name them dynamically.
<cfloop query="getCheckboxes">
<input type="checkbox" name="form.checkbox#checboxid#"<cfif
isdefined(form['checkbox' & checkboxid]> checked />
</cfloop>
Then use the same query and loop to on the action side to determine if the
checkbox exists (they only exist in the form scope if they were checked)
..:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com
-----Original Message-----
From: Cameron Johnson [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 08, 2006 10:45 AM
To: CF-Talk
Subject: Re: Looping over dynamic checkboxes
Thanks for that suggestion, Bobby.
I'm still missing something, and I think I've taken a step back. The
following code only gives me one checked checkbox when first editing the
form and no checked checkboxes during the error checking:
<cfloop query="getCheckboxes">
<cfset local.currentCheckboxID = getCheckboxes.checkboxID />
<input name="checkboxList" type="checkbox"
value="#getCheckboxes.checkboxID#"
<cfloop query="queryUser">
<cfparam name="form.checkboxList" default="#queryUser.checkboxID#"
/>
<cfif local.currentCheckboxID EQ form.checkboxList>
checked
</cfif>
</cfloop>
>
</cfloop>
Something is eluding me. Any other help?
Cameron
>Use the same loop to declare cfparams for your form fields using the query
>results as the default""
>
>Then in all of your form fields, use the form scope for the values
>
>When the user first hits the form, the query populates the form scope. When
>the user submits, THEIR information overrides the cfparams and stays in the
>form scope
>
>Works every time :-)
>(not to mention... it will get rid of all those <cfif> statements ;-)
>
>.:.:.:.:.:.:.:.:.:.:.:.:.
>Bobby Hartsfield
>http://acoderslife.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:231718
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54