troubleshooting Question

CF - Form Update

Avatar of JohnMac328
JohnMac328Flag for United States of America asked on
Microsoft SQL ServerColdFusion Language
16 Comments1 Solution453 ViewsLast Modified:
I have two forms on a page.  The first one has a select box that the user picks the employee record from.  The second one displays the details of the record.  I am try to add a edit button so they can change a value.  When I click the edit button, the page refreshes and then another choosing of an employee is required.  If you bring up the same employee the record has not changed.  
Any help is appreciated.

<cfparam name="form.ID" default="">
<cfparam name="form.totalRecords" default=0>
<cfquery name="getEmployees" datasource="datasource">
SELECT     ID, client_id, LTRIM(RTRIM(First_Name))+ ' ' + LTRIM(RTRIM(Last_Name)) As FullName , active_account
FROM         employee_data
WHERE     (active_account = 1) 
ORDER BY  First_Name, Last_Name
</cfquery>
</head>
<body>
<div id="container">
  <div id="content">
    <div id="content_main">
      <div id="header"></div>
      <h1>Performance Evaluations</h1>
      <cfform>
        <!--- change the employee viewed ---->
        
        <table class="displayTable" width="600">
        
          <th>Select Employee</th>
        <tr>
          <td width="186"><cfselect name="ID"   query="getEmployees" display="FullName" value="ID" selected="#form.ID#" onchange="this.form.submit();"> </cfselect></td>
        </tr>
      </cfform>
      <cfif val(form.ID) eq 0>
        <h3>Please select an employee</h3>
        <cfexit>
      </cfif>
      <cfquery name="getAnswers" datasource="datasource">
SELECT     TOP (41) EmployeeQuestions.QuestionNumber, EmployeeQuestions.Question, EmployeeResponse.UserResponse, EmployeeResponse.EmployeeID, 
                      employee_data.ID
FROM         EmployeeQuestions INNER JOIN
                      EmployeeResponse ON EmployeeQuestions.QuestionNumber = EmployeeResponse.QuestionNumber INNER JOIN
                      employee_data ON EmployeeResponse.EmployeeID = employee_data.ID
 WHERE     EmployeeResponse.EmployeeID = #val(form.ID)#
</cfquery>
      <cfif getAnswers.recordCount eq 0>
        <h3>Selected employee has not filled out their evaluation</h3>
        <cfexit>
      </cfif>
      <cfif isDefined("FORM.editing")>
        <cfquery datasource="#datasource#">
		UPDATE EmployeeResponse
		SET UserResponse='#FORM.UserResponse#'
where EmployeeID=#FORM.ID# and QuestionNumber=#FORM.QuestionNumber#
	</cfquery>
      </cfif>
      <p align="center"><img src="images/ratings.jpg" width="762" height="50" />
      <table  class="displayTable" border="0"  align="center"cellpadding="0" cellspacing="0">
        <thead>
          <tr>
            <th>Number</th>
            <th>Question</th>
            <th>Answer</th>
          </tr>
        </thead>
        <tbody>
        <cfform action="http://localhost/Evaluation/quiz_evaltest.cfm"  method="post">
          <cfoutput query="getAnswers">
            <cfset rowNum = getAnswers.currentRow>
            <cfinput type="hidden" name="totalRecords" value="#rowNum#">
            <tr>
              <td>#QuestionNumber#</td>
              <td>#Question#</td>
              <td><cfinput type="text" name="UserResponse" value="#UserResponse#" size="2">
                <cfinput type="hidden" name="QuestionNumber#rowNum#" value="#getAnswers.QuestionNumber#"></td>
              <td><cfinput type="submit" name="editing"
			value="EDIT" style="font-size:xx-small"></td>
            </tr>
          </cfoutput>
        </cfform>
ASKER CERTIFIED SOLUTION
Bruce Cadiz
Quality Specialist

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