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

How can I validate this ?

New Here ,
Aug 31, 2009 Aug 31, 2009

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 ?

906
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 ,
Aug 31, 2009 Aug 31, 2009

<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.

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
New Here ,
Aug 31, 2009 Aug 31, 2009

You are still validating on the server side ?

How can I validate on the client side, like using javascript ?

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
New Here ,
Sep 01, 2009 Sep 01, 2009
LATEST

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#">

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