• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

<cfloop> check box processing

New Here ,
Jul 15, 2013 Jul 15, 2013

Copy link to clipboard

Copied

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#

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

Views

512

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 15, 2013 Jul 15, 2013

Copy link to clipboard

Copied

LATEST

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation