We help IT Professionals succeed at work.
Get Started

<cfelseif> not working for update

567 Views
Last Modified: 2013-12-24
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

Comment
Watch Question
Top Expert 2011
Commented:
This problem has been solved!
Unlock 1 Answer and 15 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE