1 Reply Latest reply on Jul 15, 2013 8:01 PM by p.sim

    <cfloop> check box processing

    NC Beach Bum Level 1

      I am working on a project where there is a list of items from the database and the screen is populated with the items, description, and a checkbox for the user to select.   When the user processes the screen only those items are stored in the database.    I have it all working but no real good idea on how to save the selected items to the database.   Need some assistance on this one.


      <!--- This sould be the MS SQL --->

      <cfif isDefined('form.test')>

          <cfoutput>This is a list of the items selected</cfoutput>

          <cfloop list="#form.test#" index="i">

              <cfparam name="form.#i#" default="">

              #i#: #FORM[i]#





      <!--- Get the Data from the MS SQL Database --->

      <cfquery name="getData">






          From Position

          Where PositionLevelID = 2

          Order By ListSortOrder




      <!---  Start the screen --->

      <!DOCTYPE html>




                  Equipment Listing


              <link rel="stylesheet" type="text/css" href="../styles.css"/>



              <cfform name="testing">

                  <cfloop query="GetData">

                      <input type="checkbox" name="#GetData.Title#" value="#GetData.PositionID#"/>


                          #title# #PositionID#




                  <input name="test" type="Submit" value="testing">




        • 1. Re: <cfloop> check box processing
          p.sim Level 3

          Put "action" attribute in the cfform which assigns where you want to submit the form. Then in the action page, you use cfquery to insert the selected items to database.


          Get Ben Forta's ColdFusion book. It's all there. Or, go to easycfm.com or learncfinaweek.com. There are tons of examples!