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

Internet code

Participant ,
Apr 05, 2008 Apr 05, 2008
Somebody posted their method on how to do mass deletes with checkboxes for each line. I copied their code and it works fine.

The checkbox line is <cfinput type="checkbox" name="del_#urdn_number#" value="Yes">

When the form is submitted, the action page :

<cfif isDefined("form.FieldNames")>

<cfloop index="i" list="#form.fieldnames#" delimiters=",">

<cfif left(i,4) is "del_">
<cfset select_urdn_number = removechars(i,1,4)>
<cfset select_urdn_number = #evaluate(select_urdn_number)#>

<delete code goes here, not really a physical delete, but just updates a flag from yes to no>

</cfif>
</cfloop>

This seems to work fine, but there are now two things that I need to do.

After all of the checkbox records have been deleted (changed), I need to display to the user which ones were deleted, in the action page. My query where clause will need to use select_urdn_number from above. But if I have this outside the loop, it cannot find select_urdn_number, and if I have it inside the loop, it creates multiple records (page headings, etc.). Where should this query go ?

The second thing is if none of the checkboxes were checked on the form and the user submits, I need to send an error message back to the form indicating that no checkboxes were selected. I can insert this part as part of the <cfelse> part above, but would it be better to use javascript to validate (I dont know how to use javascript to validate against del_#urdn_number#" ). What would be the best way to do this ?

Thanks for any help.
227
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
LEGEND ,
Apr 05, 2008 Apr 05, 2008
LATEST
Instead of this,
<cfset select_urdn_number = removechars(i,1,4)>
<cfset select_urdn_number = #evaluate(select_urdn_number)#>

Build a list of numbers. Then run one query after your loop to update and select and update the records in your list.

If you are programing for the people who may not have js enabled, you still want to do server side validation. Having js run on the client is also good. I'd tell you how, but I don't know either.
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