Skip to main content
November 14, 2011
Answered

How can I get the checked item from a list that is generated automatically?

  • November 14, 2011
  • 1 reply
  • 1019 views

I am still pretty new a CF and could really use some help. I am trying to get each item that is checked from a page that generates the list automatically from a query and get the associated textbox text with it. For example:

                    <!--- Start Get Data Hierarchy List--->

                              <cfquery datasource="MyDatasource" name="qry_GetData">

                                        SELECT C.taxonomy_id, C.lvl, C.taxonomy_name, C.taxonomy_tree, C.taxonomy_guid, C.taxonomy_standard_name

                                        FROM dbo.taxonomy AS P

                                        JOIN dbo.taxonomy AS C

                                                  ON P.taxonomy_id = 21

                                                  AND C.hid.IsDescendantOf(P.hid) = 1

                                                  AND C.lvl = 3

                              </cfquery>

                    <!--- Start Get Data Hierarchy List--->









<cfloop query="qry_GetData">









<input type="checkbox" name="cbox_PE_SelTax#taxonomy_id#" value="#taxonomy_name#"><font size="4" color="3399FF"> #taxonomy_name#</font>









<br />









     - Details of experience with #taxonomy_name#:<input name="tbox_PE_SelTax#taxonomy_id#" id="tbox_PE_SelTax#taxonomy_id#" size="50%">









<br />









<br />








</cfloop>
This topic has been closed for replies.
Correct answer Dave Watts

Dave,

Thank you for your help so far. I must not be asking the right question. Here is the whole breakdown. I am writing this page to collect the users information, Name, Title, Company, and technologies they are familiar with. I then want that information emailed to me upon submission. The point I am running into a problem (even with your last post) is how to write the action part of it that will email the checked items to me. I cannot figure out if I need to use CFLOOP (if so, how) or what the best method is. I am a very visual lerner and can understand how code works easily, but I have not found any examples for my situation. Again, I really appriciate all of your help thus far.

Thank you!


If you just want the names, you could leave the value of the checkboxes set to taxonomy_name. In your action page (CFMAIL, whatever) you could just output this:

Taxonomies: #form.cbox_PE_SelTax#

Dave Watts, CTO, Fig Leaf Software

1 reply

Inspiring
November 14, 2011

Give all your checkboxes the same name,  The resulting form variable will either be undefined or a list of the checked values.

November 14, 2011

Could you elaborate a bit, please. I am very new to CF.

Community Expert
November 14, 2011

Give all your checkboxes the same name:

<input type="checkbox" name="cbox_PE_SelTax" value="#taxonomy_#"><font size="4" color="3399FF"> #taxonomy_name#</font> (Also, you might not want to use the FONT tag any more - it's been deprecated for quite some time. Try CSS instead.)

Then, in your action page, the value of Form.cbox_PE_SelTax will contain a list of all the taxonomy_id values for whichever boxes were checked. Note that I changed the value of the checkbox from taxonomy_name to taxonomy_id.

Dave Watts, CTO, Fig Leaf Software

Dave Watts, Eidolon LLC