troubleshooting Question

<cfif> not working. Pre-check values on add form being ignored

Avatar of Jerome Slaughter
Jerome SlaughterFlag for United States of America asked on
ColdFusion Language
9 Comments1 Solution378 ViewsLast Modified:
I guess i'm becoming a regular on here with asking questions but I do really love this site and appreciate all the expert help.

I have a coldfusion add new record form and would like to check the *required values before allowing the submission of the new record. The cfif that I have in the form is ignoring the checks. Below are the code for both forms.
<!--- Add New Record form ---
================================ --->

<!--- query to put a list of of Request options in a dropdown box during an insert --->
<cfquery name="dropdownvalues" datasource="sspsrs">
    SELECT Title_Name
    FROM IssueTitles order by Title_Name
</cfquery>

<!--- query to put a list of of SSP Internal network names from the database in a dropdown box during an insert --->
<cfquery name="ddvsnetwork" datasource="sspsrs">
    SELECT Network
    FROM Network
</cfquery>

<cfquery name="clas" datasource="sspsrs">
    SELECT Classification
    FROM Classification
</cfquery>


<!--- query to put a list of "Full_names" names from the database in a dropdown box during an insert --->
<cfquery name="fname" datasource="sspsrs">
    SELECT Full_name
    FROM tblAdmins order by full_name
</cfquery>

<!--- query to put a list of customer "Last Names" from the database in a dropdown box during an insert --->
<cfquery name="ln" datasource="sspsrs">
    SELECT distinct Last_Name
    FROM Customers order by last_name
</cfquery>

<!--- query to put a list of customer "First Names" from the database in a dropdown box during an insert --->
<cfquery name="fn" datasource="sspsrs">
    SELECT distinct First_Name
    FROM Customers order by first_name
</cfquery>

<cfquery name="rstatus" datasource="sspsrs">
    SELECT status
    FROM Status
</cfquery> 

<cfquery name="pr" datasource="sspsrs">
    SELECT priority
    FROM priority
</cfquery>


    <cfoutput><a href="trackertabs.cfm?user_name=#url.user_name#&tab=2"></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>

<body bgcolor="#99ccff">
	<table width="100%" border="0">
<br>
<font size = 4><b><u>Add A New Service Request</u></font>
<br>
<br>
==========<Br>
* Required<br>
==========<br>
<cfoutput>

<cfform action="http://127.0.0.1:8500/TicketTracking/insertnewsr.cfm?user_name=#url.user_name#" method="Post">
  			
			<tr>
				  <td><br><b>* Request Type:</b></br></td>
				  <td><select name="Title">
                                  <option value="">---Select Option---</option>
				  <cfloop query="dropdownvalues">
				  <option value="#dropdownvalues.title_name#">#dropdownvalues.title_name#</option>
				  </cfloop>
				  </select></td>
				  
			
			</tr>
			<tr>
				<td><br><b>* Opened Date:</b></br></td>
				<td><cfinput name="Opened_Date" type="datefield" validate="date" monthnames="Jan,Feb,March,April,May,June,July,August,September,October,November,December"></td>
			</tr>
			
  			<tr>
				<td><br><b>* Network:</b></br></td>
				  <td><select name="Network">
				  <option value="">---Select Option---</option>
				  <cfloop query="ddvsnetwork">
				  <option value="#ddvsnetwork.network#">#ddvsnetwork.network#</option>
				  </cfloop>
				  </select></td>
			<tr>
				<td><br><b>* Classification <br>of Request:</b></br></td>
				  <td><select name="classification_of_Request">
				  <option value="">---Select Option---</option>		
				  <cfloop query="clas">
				  <option value="#clas.classification#">#clas.classification#</option>
				  </cfloop>
				  </select></td>
  			</tr>
  			<tr>
  				
				  <td><br><b>* Assigned To:</b></br></td>
				  <td><select name="Full_Name">
				  <option value="">---Select Option---</option>
				  <cfloop query="fname">
				  <option value="#fname.Full_Name#">#fname.Full_name#</option>
				  </cfloop>
				  </select></td>
  			</tr> 
  			
  			<tr>      <td><br><b>* Customer <br> Last Name:</b></br></td>
				  <td><select name="Last_Name">
				  <option value="">---Select Option---</option>
				  <cfloop query="ln">
				  <option value="#ln.Last_Name#">#ln.last_name#</option>
				  </cfloop>
				  </select></td>
  			</tr> 
  			<tr>
				  <td><br><b>* Customer <br> First Name:</b></br></td>
				  <td><select name="First_Name">
				  <option value="">---Select Option---</option>
				  <cfloop query="fn">
				  <option value="#fn.First_Name#">#fn.first_name#</option>
				  </cfloop>
				  </select></td>
  			</tr>
  			
			<tr>
				<td><br><b>Closed Date:</b></br></td>
				<td><cfinput name="Closed_Date" type="datefield" validate="date" monthnames="Jan,Feb,March,April,May,June,July,August,September,October,November,December"></td>
			</tr>
  			<tr>
				 <td><br><b>* Status:</b></br></td>
				  <td><select name="Status">
				  <option value="">---Select Option---</option>
				  <cfloop query="rstatus">
				  <option value="#rstatus.status#">#rstatus.status#</option>
				  </cfloop>
				  </select></td>
  			</tr>
			<tr>
				  <td><br><b>* Priority:</b></br></td>
				  <td><select name="priority">
				  <option value="">---Select Option---</option>
				  <cfloop query="pr">
				  <option value="#pr.priority#">#pr.priority#</option>
				  </cfloop>
				  </select></td>
  			</tr>
			<tr>
				<td><br><b>Description:</b></br></td>
				<td><font size=2><textarea name="description" rows="5" cols="40"></textarea></td>
  			</tr>
			
			<tr>
				<td><br><b>Comments:</b></br></td>
				<td><font size=2><textarea name="comments" rows="5" cols="40"></textarea></td>
  			</tr> 

			<tr>
				<td> <br></td>
				<td><cfinput type = "submit" name="insert" class="button" value = "Add New Record"  
									onClick="return confirm('Are You Sure You Want To Add This Record?');"></br></td>
			</tr>
		</cfform>
		</cfoutput>
</table>
</body>

<!--- ============ INSERT RECORD FORM ====
-------------------------------------------->


<!---<cfdump var="#FORM#" label="FORM variables">--->

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

<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/addnewsr.cfm?<cfoutput>user_name=#url.user_name#</cfoutput>";
</script>

<!--- THIS IS WHERE I'M HAVING THE PROBLEM --->

<cfif #form.title# is "">
<script>
              alert("You must select a Request Type!");
              self.location="http://127.0.0.1:8500/TicketTracking/addnewsr.cfm?user_name=#url.user_name#";
</script>


<cfelse>



<CFQUERY NAME="insert" DATASOURCE="sspsrs">
INSERT INTO Issues (Title, Network, Classification_of_Request, Full_Name, Last_Name, First_Name, 
Opened_Date, Closed_Date, Status, Priority, Description, Comments, user_name)
  VALUES('#Form.title#', '#Form.network#', '#Form.classification_of_request#', '#Form.full_name#',
         '#Form.Last_Name#', '#Form.First_Name#',<cfqueryparam value="#DateFormat(Form.Opened_Date, 'mm/dd/yyyy')#" cfsqltype="cf_sql_date">, <cfqueryparam value="#DateFormat(Form.Closed_Date, 'mm/dd/yyyy')#" cfsqltype="cf_sql_date">, '#Form.status#', 
         '#Form.priority#', '#Form.description#', '#Form.comments#', <cfqueryparam value="#addun.user_name#" cfsqltype="cf_sql_varchar">)
</CFQUERY>


<script>
              alert("New Service Request has been added successfully!");
              self.location="http://127.0.0.1:8500/TicketTracking/trackertabs.cfm?<cfoutput>user_name=#url.user_name#&tab=2</cfoutput>";
</script>

</cfif>

Open in new window

ASKER CERTIFIED SOLUTION
gdemaria

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 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 9 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