Form Checkbox Custom Tag

Download FormCheckbox.zip (2K)

Description

Requires ColdFusion 5 or greater.

FormCheckbox.cfm is a ColdFusion custom tag that creates standard group HTML form checkboxes from a field name. Use of the <LABEL> tag allows the label to be clicked to select the checkbox (in compliant browsers).

Syntax

<CF_FormCheckbox
	FIELD="form field name" 
	[VALUE="checkbox value"]
	[LABEL="checkbox label"]
	[LABELALIGN="b|a"]
	[SELECTED="list of selected values"] 
	[DELIM="list delimiter"]
	[ALIGN="h|v"]
	[ONCLICK="javascript"]
	[COMPRESS="boolean"]
>

Attributes

ALIGN     (optional, string)     Alignment of multiple checkboxes: h = horizontal alignment (default), v = vertical alignment.
COMPRESS     (optional, string)     Remove all whitespace from generated code other than single spaces. Default is "YES".
DELIM     (optional, string)     Delimiter used by all lists. Default is comma (",").
FIELD     (REQUIRED, string)     A valid HTML form field name for the checkbox set.
LABEL     (optional ,string/list)     A checkbox label or delimited list of labels. Default is no label. If multiple labels are used, number of values must match number of labels.
LABELALIGN     (optional, string)     Alignment of label. b = before checkbox, a = after checkbox (default)
ONCLICK     (optional, string)     JavaScript to execute when the checkbox is clicked.
SELECTED     (optional, string/list)     A delimited list of checkbox values to mark as checked. Default is none checked.
VALUE     (optional, string/list)     A checkbox value or delimited list of values. Default is "True".
If multiple values are used:
1) multiple checkboxes will be created with the same field name which produces a comma-delimited list of values when the form is submitted
2) Number of values must match number of labels

Examples

<CF_FormCheckbox FIELD="ShowBorder" LABEL="Show table border">
Please select magazines:    

<B>Please select magazines:</B>
<CF_FormCheckbox 
	FIELD="Mags" 
	VALUE="TI,NW,BY" 
	LABEL="Time,Newsweek,BYTE" 
	SELECTED="NW,BY">

Site last updated: 11 March 2012