Question
Error messages insert
I was given the code below and I just added the query.
The problem I am having is the error messages. I am not sure where they go.
I have a form with checkboxes and comments.
If they submit without checking a box, then it should
return to the form and popup an error message.
If they check a box but do not enter comments, then it
should return to the form with an error message.
It they check at least one box and enter comments,
then it should go to another screen with a successful
message.
Everything seems to work except for the last record
remaining. For example, if there are three line items
and the first two are deleted, it returns to the form
and popsup the checkbox error message, which it should
not. It should be redirected to another page with a
successful message.
I think I just have the messages in the wrong spot.
Here is the code :
<cfif StructKeyExists( form, "fieldnames" )>
<cfloop index="i" list="#trim( form.fieldnames) #">
<cfif ListFirst(i, "/") is "comments">
<cfset select_ref_number = listgetat(i, 2,
"/")>
<cfset select_ref_line_ item = listlast(i,
"/")>
<cfset combineEnd = select_ref_number & "/"
& select_ref_line_ item>
<!--- Add this to check for the checkbox --->
<cfif StructKeyExists( form, "del/" &
combineEnd) and form["del/" & combineEnd] is "Yes">
<cfset commentsName = "comments/" &
combineEnd>
<cfset select_comments =
form[commentsName] >
<cfif len(trim(select_ comments) ) eq 0>
If comments are blank, return to form with comments <==== error message
required error
</cfif>
<cfquery name="qryUpdate_ ref_Line_ Items"
datasource=" recDisc">
update test_UnReceivables_ ref_Line_ Items
set current_state = 'Voided'
where ref_number = '#select_ref_ number#'
and ref_line_item = '#select_ref_ line_item# '
</cfquery>
<cfquery name="qryInsert_ Activity_ Log"
datasource=" recDisc">
insert into test_UnReceivables_ Activity_ Log
(activity_transacti on_id,
activity_id,
user_employee_ number,
activity_date,
comments,
ref_number,
line_item)
values
('#act_txn_id# ',
'7',
'#cgi.remote_ user#',
#createODBCDateTime (Now())#,
'#select_comments# ',
'#select_ref_ number#',
'#select_ref_ line_item# ')
</cfquery>
</cfif>
</cfif>
</cfloop>
If no checkbox is selected, return to form here and <==== error message
display checkbox error message
<cfelse>
If everythign passes, redirect to another page and <===== message
display a successful message
</cfif>
Thanks for your help.
The problem I am having is the error messages. I am not sure where they go.
I have a form with checkboxes and comments.
If they submit without checking a box, then it should
return to the form and popup an error message.
If they check a box but do not enter comments, then it
should return to the form with an error message.
It they check at least one box and enter comments,
then it should go to another screen with a successful
message.
Everything seems to work except for the last record
remaining. For example, if there are three line items
and the first two are deleted, it returns to the form
and popsup the checkbox error message, which it should
not. It should be redirected to another page with a
successful message.
I think I just have the messages in the wrong spot.
Here is the code :
<cfif StructKeyExists( form, "fieldnames" )>
<cfloop index="i" list="#trim( form.fieldnames) #">
<cfif ListFirst(i, "/") is "comments">
<cfset select_ref_number = listgetat(i, 2,
"/")>
<cfset select_ref_line_ item = listlast(i,
"/")>
<cfset combineEnd = select_ref_number & "/"
& select_ref_line_ item>
<!--- Add this to check for the checkbox --->
<cfif StructKeyExists( form, "del/" &
combineEnd) and form["del/" & combineEnd] is "Yes">
<cfset commentsName = "comments/" &
combineEnd>
<cfset select_comments =
form[commentsName] >
<cfif len(trim(select_ comments) ) eq 0>
If comments are blank, return to form with comments <==== error message
required error
</cfif>
<cfquery name="qryUpdate_ ref_Line_ Items"
datasource=" recDisc">
update test_UnReceivables_ ref_Line_ Items
set current_state = 'Voided'
where ref_number = '#select_ref_ number#'
and ref_line_item = '#select_ref_ line_item# '
</cfquery>
<cfquery name="qryInsert_ Activity_ Log"
datasource=" recDisc">
insert into test_UnReceivables_ Activity_ Log
(activity_transacti on_id,
activity_id,
user_employee_ number,
activity_date,
comments,
ref_number,
line_item)
values
('#act_txn_id# ',
'7',
'#cgi.remote_ user#',
#createODBCDateTime (Now())#,
'#select_comments# ',
'#select_ref_ number#',
'#select_ref_ line_item# ')
</cfquery>
</cfif>
</cfif>
</cfloop>
If no checkbox is selected, return to form here and <==== error message
display checkbox error message
<cfelse>
If everythign passes, redirect to another page and <===== message
display a successful message
</cfif>
Thanks for your help.
