Checkboxes are checked when they should not be ...
Posted on 2006-06-04
I have a form that displays the existing values in a database.
Two of the fields are checkboxes. The values in the database are "0" or "1" (0 for false or no, 1 for true or yes).
I'm displaying the fields in a repeat region (see code below).
All of the checkboxes that SHOULD be checked are checked ...BUT ... so are many others that should not be checked.
Values are displayed in a table with a column for IngrName, a column for Pantry (checkbox), and column for StockItem (checkbox).
In the display of the data, everything up to & including the last record for which Pantry=true is checked displays a checkmark in the box. Ditto for the StockItem checkbox.
I have tested the recordset and the values are indeed what I think they are ... they are not all checked as the display would lead you to believe.
IngrID is the primary key.
For the IIF clauses, I've tried comparing to "1" and "true" with the exact same results.
I've successfully displayed checkbox fields using code like this before; the only difference was those were all strung out on one line and there was a separate field in the database for each one.
So this must have something to do with using the repeat region and a record set but I am at a loss.
What the heck is going on?
Here's my code:
<input type="checkbox" name="item_#rs_Ingredients.IngrID#" />
<input name="pantry_#rs_Ingredients.IngrID#" type="checkbox"
<cfoutput>#IIF(rs_Ingredients.Pantry eq "yes",DE("checked"),DE(""))#</cfoutput>/>
<input name="stock_#rs_Ingredients.IngrID#" type="checkbox"
<cfoutput>#IIF(rs_Ingredients.StockItem eq "yes",DE("checked"),DE(""))#</cfoutput>/>