Form Radio Button Custom Tag

Download FormRadio.zip (2K)

Description

Requires ColdFusion 5 or greater.

FormRadio.cfm is a ColdFusion custom tag that creates a standard group of HTML form radio buttons from a field name and a list of values. Use of the <LABEL> tag allows the label to be clicked to select the radio button (in compliant browsers).

Syntax

<CF_FormRadio
	FIELD="form field name" 
	VALUES="list of values" 
	[LABELS="list of labels"]
	[SELECTED="selected value"]
	[DELIM="list delimiter"]
	[ALIGN="h|v"]
	[ONCLICK="javascript"]
	[COMPRESS="boolean"]
>

Attributes

ALIGN     (optional, string)     Alignment of buttons: 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 to use for lists. Default is a comma (",").
FIELD     (REQUIRED, string)     A valid HTML form field name for the radio button set.
LABELS     (optional, string list)     A delimited list of labels for the radio buttons. If provided, number of labels must equal number of values. If omitted, values are used as labels.
ONCLICK     (optional, string)     JavaScript to execute when a button is clicked.
SELECTED     (optional, string)     Value of the radio button to mark as selected. If omitted or not present in list of values, first value is used.
VALUES     (REQUIRED, string list)     A delimited list of values for the radio buttons. List must contain at least two items. If no labels are provided, these will also be used as labels.

Examples

Did you find what you needed?  

<B>Did you find what you needed?</B>
<CF_FormRadio FIELD="YesNoQuestion" VALUES="Yes,No">

Please rate our product    

<B>Please rate our product</B>
<CF_FormRadio 
	FIELD="RatingScale" 
	VALUES="1,2,3" 
	LABELS="Poor,Good,Excellent" 
	SELECTED="2">

Shipping method:


<B>Shipping method:</B>
<BR><CF_FormRadio 
	FIELD="Shipping" 
	VALUES="1:2:3" 
	LABELS="FedEx, Ground:UPS, Overnight:UPS, 2nd Day" 
	DELIM=":" 
	ALIGN="v">

Site last updated: 11 March 2012