Skip navigation
KristopherKick
Currently Being Moderated

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

Nov 14, 2011 8:13 AM

Tags: #list #coldfusion #checkbox #cfloop

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>
 
Replies
  • Currently Being Moderated
    Nov 14, 2011 9:24 AM   in reply to KristopherKick

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

     
    |
    Mark as:
  • Dave Watts
    747 posts
    Mar 11, 2003
    Currently Being Moderated
    Nov 14, 2011 12:59 PM   in reply to KristopherKick

    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

     
    |
    Mark as:
  • Dave Watts
    747 posts
    Mar 11, 2003
    Currently Being Moderated
    Nov 14, 2011 1:35 PM   in reply to KristopherKick

    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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points