troubleshooting Question

<cfelseif> not working for update

Avatar of Jerome Slaughter
Jerome SlaughterFlag for United States of America asked on
Web ServersColdFusion Language
15 Comments1 Solution569 ViewsLast Modified:
1. i have a display form myopensrs.cfm that displays results.

2. the display form references the update form update_action.cfm

i would like to do some pre-checks of values before the submission of the form. the inital <cfif> works but the <cfelseif> is not working. It ignores the check of the form values and doesn't display the message set in the <cfelseif>. The code is below.
================
myopensrs.cfm
================


<!--- headers --->
    <cfoutput><a href="trackertabs.cfm?user_name=#url.user_name#&tab=2"></cfoutput>    
    <img src="http://127.0.0.1:8500/TicketTracking/pics/imagesCA6WFWX0.jpg" width=50 height=50 alt="go back to service tab" border="0" /></a>


<!--- Query the database for all open service requests (per user log in) --->
<cfquery name="Getmyrequests" datasource="sspsrs">
    SELECT    * 
    FROM    Issues 
    WHERE   status = 'active' and user_name = <cfqueryparam value="#url.user_name#" cfsqltype="cf_sql_varchar">
    order by ticket_num
</cfquery>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<title>My Open Service Requests</title>
	</head>
	<body>
<font size=6><i><CENTER>My Open Service Requests</center></i></font>
        

<table border='0' width="100%" align='center' summary='script output'>
    <tr bgcolor="#99ccff">
        <th bgcolor="#99ccff"><font size=2><b>Service<br> Request #</b></font></th>
        <th bgcolor="#99ccff"><font size=2></strong>Request</strong></font></th>
        <th bgcolor="#99ccff"><font size=2></strong>Network</strong></font></th>
	<th bgcolor="#99ccff"><font size=2></strong>Classification<br>of Request</strong></font></th>
        <th bgcolor="#99ccff"><font size=2></strong>Assigned<br> To</strong></font></th>
        <th bgcolor="#99ccff"><font size=2></strong>Customer<br>Last Name</strong></font></th>
	<th bgcolor="#99ccff"><font size=2></strong>Customer<br>First Name</strong></font></th>
        <th bgcolor="#99ccff"><font size=2></strong>Opened<br> Date</strong></font></th>
        <th bgcolor="#99ccff"><font size=2></strong>Closed<br>Date Date</strong></font></th>
        <th bgcolor="#99ccff"><font size=2></strong>Status</strong></font></th>
        <th bgcolor="#99ccff"><font size=2></strong>Priority</strong></font></th>
        <th bgcolor="#99ccff"><font size=2></strong>Description</strong></font></th>
        <th bgcolor="#99ccff"><font size=2></strong>Comments</strong></font></th>
        <th bgcolor="#99ccff"><font size=2></strong>Update<br> Service<br> Request</strong></font></th>
    </tr>
<!--- Output a table containing each service requests.  Create dynamic
		  links to edit and delete the service.  Pass the ID
		  associated with each record in the URL of the link --->

            <cfoutput query="Getmyrequests">
			  
            <tr bgcolor="###iif(currentrow MOD 2,DE('ffffff'),DE('cccccc'))#">
            <td><font size=2>#Ticket_num#</font></td>
            <td><font size=2>#Title#</font></td>
            <td><font size=2>#Network#</font></td>
	    <td><font size=2>#Classification_of_Request#</font></td>
            <td><font size=2>#Full_name#</font></td>
            <td><font size=2>#Last_Name#</font></td>
	    <td><font size=2>#First_Name#</font></td>
            <td><font size=2>#DateFormat(Opened_Date,'mm/dd/yyyy')#</font></td>
            <td><font size=2>#DateFormat(Closed_Date,'mm/dd/yyyy')#</font></td>
            <td><font size=2>#Status#</font></td>
            <td><font size=2>#Priority#</font></td>
            <td><font size=2>#Description#</font></td>
            <td><font size=2>#Comments#</font></td>
	    <td><a href="http://127.0.0.1:8500/TicketTracking/update_sr.cfm?user_name=#url.user_name#&ticket_num=#ticket_num#">Update</a></td>
			  </tr>
			</cfoutput>
             
			  
		</table>
	</body>
</html>

==================
update_action.cfm
==================

<cfquery name="changeun" datasource="sspsrs">
    SELECT user_name
    FROM tblAdmins where Full_name = <cfqueryparam value="#form.full_name#" cfsqltype="cf_sql_varchar"> 
</cfquery>


  <cfoutput><a href="myopensrs.cfm?user_name=#url.user_name#"></cfoutput>    
    <img src="http://127.0.0.1:8500/TicketTracking/pics/returnwc.jpg" width=60 height=60 alt="go back to service tab" border="0" /></a>
<br>
<br>
<body bgcolor="#99ccff">


<cfif #form.status# is 'Resolved' and #form.closed_date# is "">
<script>
              alert("Please choose a closed date before closing this service request.");
              self.location="http://127.0.0.1:8500/TicketTracking/update_sr.cfm?<cfoutput>user_name=#url.user_name#&ticket_num=#ticket_num#</cfoutput>";
</script>

<!--- =========== having problems with this <cfelseif> here
=================--->
<cfelseif #form.status# = 'Active'>

<script>
              alert("Please change the status to "resolve" before closing this service request.");
              self.location="http://127.0.0.1:8500/TicketTracking/update_sr.cfm?<cfoutput>user_name=#url.user_name#&ticket_num=#ticket_num#</cfoutput>";
</script> 





<cfelse>

<!--- Update the record, and write the new data to the database --->
	  <cfquery datasource="sspsrs">
  		UPDATE Issues
  		SET		
				title= <cfqueryparam value="#Form.title#" cfsqltype="cf_sql_varchar">,
				network= <cfqueryparam value="#Form.Network#" cfsqltype="cf_sql_varchar">,
				Classification_of_Request= <cfqueryparam value="#Form.Classification_of_Request#" cfsqltype="cf_sql_varchar">,
				full_name= <cfqueryparam value="#Form.full_name#" cfsqltype="cf_sql_varchar"> ,
				
				user_name= <cfqueryparam value="#changeun.user_name#">,

				Last_Name= <cfqueryparam value="#Form.Last_Name#" cfsqltype="cf_sql_varchar">,
				First_Name= <cfqueryparam value="#Form.First_Name#" cfsqltype="cf_sql_varchar">,
				Opened_Date= <cfqueryparam value="#DateFormat(Form.Opened_Date, 'mm/dd/yyyy')#" cfsqltype="cf_sql_date">,
				closed_date= <cfqueryparam value="#DateFormat(Form.closed_date, 'mm/dd/yyyy')#" cfsqltype="cf_sql_date">,
				status= <cfqueryparam value="#Form.status#" cfsqltype="cf_sql_varchar">,
				priority= <cfqueryparam value="#Form.priority#" cfsqltype="cf_sql_varchar">,
				description= <cfqueryparam value="#Form.description#" cfsqltype="cf_sql_varchar">,
				comments= <cfqueryparam value="#Form.comments#" cfsqltype="cf_sql_varchar">

	WHERE ticket_num = <cfqueryparam value="#url.ticket_num#" cfsqltype="cf_sql_integer">								  
	  </cfquery>
</cfif>

	  <!--- display the tip that was entered into the database--->
		  <font size = 4 font color="#ffffff"><b>The following Service Request was updated:</b></font>	<br /> <br />  <br />  
  	  <cfoutput>
		
		<b>Service Request:</b> - #url.ticket_num# <br  /><br />
		<b>Title:</b> - #Title# <br  /><br /> 
		<b>Network:</b> - #Network# <br  /><br /> 
		<b>Classification of Request:</b> - #Classification_of_Request#  <br  /><br /> 
		<b>Assigned To:</b> - #full_name#  <br  /><br />
		<!---<b>User Name:</b> - #user_name# <br  /><br />---> 
		<b>Last Name:</b> - #Last_name# <br  /><br /> 
		<b>First Name:</b> - #First_name# <br  /><br /> 
		<b>Opened Date:</b> - #Opened_Date# <br  /><br /> 
		<b>Closed Date:</b> - #Closed_Date# <br  /><br /> 
		<b>Status:</b> - #status# <br  /><br /> 
		<b>Priority:</b> - #priority# <br  /><br /> 
		<b>Description:</b> - #description# <br  /><br /> 
		<b>Comments:</b> - #comments# <br  /><br /> 
	  </cfoutput>
	  <br /> <br /> 
	

</body>

Open in new window

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 15 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros