Skip navigation
NC Beach Bum
Currently Being Moderated

<cfloop> check box processing

Jul 15, 2013 6:48 PM

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]#

        <br>

    </cfloop>

</cfif>

 

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

<cfquery name="getData">

    Select

    PositionID,

    PositionLevelID,

    Title,

    ListSortOrder

    From Position

    Where PositionLevelID = 2

    Order By ListSortOrder

</cfquery>

 

 

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

<!DOCTYPE html>

<html>

    <head>

        <title>

            Equipment Listing

        </title>

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

    </head>

    <body>

        <cfform name="testing">

            <cfloop query="GetData">

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

                <cfoutput>

                    #title# #PositionID#

                    <br>

                </cfoutput>

            </cfloop>

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

        </cfform>

    </body>

</html>

 
Replies
  • Currently Being Moderated
    Jul 15, 2013 8:01 PM   in reply to NC Beach Bum

    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!

     
    |
    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