Solved

Build list from check boxes

Posted on 2014-03-17
3
189 Views
1 Endorsement
Last Modified: 2014-04-04
I am outputting a list of checkboxes and their values using the code below. When the user hits submit, I'd like to add the value of each checkbox to a list. Could someone assist with this? I'm not sure how to collect the checkboxes that were selected and add them to a ColdFusion list.

Thank you!

<cfquery name="getcars" ...>

				Select distinct CarName
				from tblCars
</cfquery>

  <cfoutput query="getcars">
            
        <td>#CarName#</td>
        <td>
            <input type="checkbox" name="CarName" value="#CarName#">  <br>
        </td>
        
    </cfoutput>

Open in new window

1
Comment
Question by:earwig75
3 Comments
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 39935467
easy, it is done for you.

The variable FORM.CarName   will be a comma delimited list of all checked values after the form is submitted

Its automatic
0
 
LVL 4

Expert Comment

by:Rodrigo Munera
ID: 39935929
One thing to take into account, if the user doesn't check any boxes, form.carname will not exist in the action page, so make sure you use cfparam on the action page so you don't run into syntax exceptions.
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 39977937
provide the client side validation just to make sure at least one checkbox is checked
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question