Skip to main content
January 11, 2009
Question

please help me with code

  • January 11, 2009
  • 2 replies
  • 399 views
I have a mailbox set up where depending on the number of messages there are, there are the same number of checkboxes named "form.box"(each one with a unique number at the end, the first message would be form.box1, then form.box2, so on depeding on how many messages there are), with a value of the messageid parralel to that checkbox. When i submit my form, i have this loop, nummessages is a variable that contains a number representing the total number of messages in the inbox folder.
    This topic has been closed for replies.

    2 replies

    Inspiring
    January 11, 2009
    You are welcome. Just a tip, most CF scopes are structures: form, url, session, etcetera. So you use array notation with any of those scopes as well. Happy coding ;-)
    Inspiring
    January 11, 2009
    FORM is a structure, which means you can use array notation to access the field names:

    <cfloop ....>
    <cfoutput>
    #form["box"& i]#
    </cfoutput>
    </cfloop>

    bje98f wrote:
    > so that i can call a query to delete the message that is selected...

    However, there is a more elegant option for deleting multiple records at the same time. Give all of the checkboxes the _same_ name. The form field value will then be a comma separated list of id's. Then run a single query, using that value and the IN operator. Obviously validate the list is not empty first.

    DELETE FROM YourTable
    WHERE ID IN
    (
    <cfqueryparam value="#form.box#" list="true" cfsqltype="(your type here)">
    )

    January 11, 2009
    IT WORKS!!! THANK YOU THIS WAS DRIVING ME CRAZY :)