Copy link to clipboard
Copied
I have a form with three radio buttons. When I check the first button, it will popup some fields for entry. When I check the second button, it will poup another set of fields for entry. When I click the third button,it will go to a completely new page.
When I clickk the first button, it will popup some fields for entry. The first column is a checkbox and is defined as :
<cfinput type="checkbox" name="del/#urdn_number#/#urdn_line_item#">
What I want to do is that for each record that has the checkbox checked, I want to delete that record from the table (not really a physical delete, but just changing the status flag), and comments must be entered to explain why this record is being deleted.
Here is the code that somebody heled me with and that I am using, seems to work fine.
<cfif StructKeyExists(form, "fieldnames")>
<!--- Loop thru each checked box and extract the urdn number and Entry Item for that checked line --->
<cfloop index="i" list="#trim(form.fieldnames)#">
<cfif ListFirst(i, "/") is "comments">
<cfset select_urdn_number = listgetat(i, 2, "/")>
<cfset select_urdn_line_item = listlast(i, "/")>
<cfset combineEnd = select_urdn_number & "/" & select_urdn_line_item>
<cfif StructKeyExists(form, "del/" & combineEnd) and form["del/" & combineEnd] is "Yes">
<cfset select_comments = form["comments/" & combineEnd]>
<!--- Update the Entry Items table with void, for the urdn number and Entry Item --->
<cfquery name="qryUpdate_urdn_Line_Items" datasource="recDisc_test">
update UnReceivables_urdn_Line_Items
set current_state = 'Voided'
where urdn_number = '#select_urdn_number#'
and urdn_line_item = '#select_urdn_line_item#'
</cfquery>
What I do not know how to do is to validate that the checkbox was checked if they wish to delete that racord, and that the comments were entered.
I previously did all the validation on the server side then returned the error messages but that takes alot of overhead. How can I validate on the client side before submitting the form ?
Copy link to clipboard
Copied
<cfloop index="i" list="#form.fieldnames#">
<cfif left(i,3) is "del">
<cfscript>
ThisNumber = ListGetAt(i, 2, "/");
ThisLineItem = ListLast(i, "/");
ThisComment = form["comment/" & ThisNumber & "/" & ThisLineItem];
You should be able to take it from here.
Copy link to clipboard
Copied
You are still validating on the server side ?
How can I validate on the client side, like using javascript ?
Copy link to clipboard
Copied
If I have this for my checkbox, how do I validate it ? The checkbox name with the # is throwing me off.
<cfinput type="checkbox" name="del/#urdn_number#/#urdn_line_item#">