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

please help me with code

Guest
Jan 11, 2009 Jan 11, 2009
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.
402
Translate
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
Valorous Hero ,
Jan 11, 2009 Jan 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)">
)

Translate
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
Guest
Jan 11, 2009 Jan 11, 2009
IT WORKS!!! THANK YOU THIS WAS DRIVING ME CRAZY 🙂
Translate
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
Valorous Hero ,
Jan 11, 2009 Jan 11, 2009
LATEST
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 😉
Translate
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