Question
Internet code
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.
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.
