[closed] List.cfc creates invalid HTML code


There is a problem with the code that /packages/formtools/list.cfc produces in the edit function (starting line 158).

This applies to all list types but for example if you create a list of checkboxes, the code at line 212 results in every checkbox having the same ID.

<input type="checkbox" name="#arguments.fieldname#" class="checkboxInput #IIF(listLen(lData) eq tmpCount ,DE(" #arguments.stMetadata.ftClass#"),DE(""))#" id="#arguments.fieldname#" value="#optionValue#"<cfif listFindNoCase(arguments.stMetadata.value, optionValue)> checked="checked"</cfif> />

This creates invalid HTML code.


Having had a very quick look around …

Only applies to radio buttons and checkboxes, not dropdowns.

The javascript seems to be name based. One approach could be to simply remove the ID from checkboxes and radio buttons. Another would be to append tmpCount (which doesn’t seem to be doing anything) to the ID although this is not guarenteed to unique either.

I look forward to hearing what the others say about this.

Since the id attribute isn’t used for either the checkbox or radio button elements I think the best approach is to remove it. DOM selectors written in JavaScript can still match on the value attribute if they need to, and then later if a unique ID is required for some purpose then we can add it.

I’ll patch this shortly.

Patched in p700 and p710 :smile:


Excellent. Thanks Justin!

Although I personally don’t use them for checkboxes or radio buttons, I do often write custom edit.cfm files for the webtop so that I can write custom javascript which refers to form element ids (usually select dropdowns). Hopefully I won’t need to use the ids in the future for those elements :slight_smile: