Discussion:
Array of Checkboxes
(too old to reply)
Hulfy
2009-04-03 11:45:08 UTC
Permalink
Hi,

I have an old PHP script that I am converting to coldfusion, I have an array
of checkboxes which in PHP was created by adding square brackets. When I try
this in CF I get [b]Element ROOMS is undefined in FORM. [/b]

How do I create and access an array of checkboxes in CF?

<label> Type of Room </label>

<h3> DOUBLE </h3> <input name="rooms[]" id="double"
type="checkbox" value="double" />
<h3> TWIN </h3><input name="rooms[]" type="checkbox"
value="twin" />
<h3> TRIPLE </h3><input name="rooms[]" type="checkbox"
value="triple" />
<h3> FAMILY</h3> <input name="rooms[]" type="checkbox"
value="family" />
Dan Bracuk
2009-04-03 12:22:02 UTC
Permalink
The simplest way to do check boxes is to give them all the same name and forget about arrays. When you submit the form, you will either have a list or nothing whatsoever.
tclaremont
2009-04-03 13:33:41 UTC
Permalink
Make sure you check for IsDefined in the event that the list is empty on the processing page, or else you will get an error.
Loading...