Reputation: 21
Long story short, I'm working on an application where CRUD is performed against a MySQL database. Everything is working great, except on the updating portion. I have an HTML form that the user submits to the database, and a separate page where a specific record (event) is pulled back into the form and populates the inputs. All of the other inputs are working properly, but my checkbox block is struggling.
Each checkbox input tag has this associated ColdFusion code (cfloop, cfif). The loop determines if the value is included in the list returned from the database and displays "Checked" if true:
<!--Each input has a cfloop and cfif tag to determine checked checkboxes-->
<input
type="checkbox"
id="alumni_relations"
value="Alumni Relations"
name="cboxes"
<cfloop index="foundRecord.event_type" list="#foundRecord.event_type#" delimiters=",">
<cfoutput>
<cfif #foundRecord.event_type# EQ "Alumni Relations">Checked</cfif>
</cfoutput>
</cfloop>
>
<label for="alumni_relations">Alumni Relations</label>
<br>
It works great! But for whatever reason it is only returning "Checked" for the first listed, and last listed item in the list (e.g a list of: Alumni Relations,Athletics,Management Society,Colleges will only return "Checked" for Alumni Relations and Athletics) Here's a picture of that:
Checkbox Example Image
I'm thinking it has to do something with the index, but I've scoured the documentation for cfloop and I'm just not figuring it out. Anyone with any help/advice would be much appreciated!
Upvotes: 1
Views: 153