Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable not updating with new cfset

Status
Not open for further replies.

mjstone323

Technical User
Jan 11, 2002
57
0
0
US
Hello there -

I've got my page working pretty well but I have a puzzling problem. My variable "sHeaderMessage", which I'm using to communicate with the user, isn't updating at the end of each cfif.
What's weird is that it works just fine on the other pages - but here, it gets set once and then never updates. What am I doing wrong?

Here's the code. Thanks much in advance for your help!
Code:
<link rel="STYLESHEET" type="text/css" href="/textbooks/styles.css">
<cfset sHeaderMessage="Here is the textbook information.">
<cfinclude template="/textbooks/header.cfm" />
<cfif NOT IsDefined ('URL.TextbookID') AND IsDefined('FORM.TextbookID')>
	<cfset URL.TextbookID = FORM.TextbookID />
</cfif>

<cfif NOT IsDefined ('URL.TextbookID')>
	<cflocation url="textbook_list.cfm?SchoolID=#getSalutation.s_SchoolID#">
</cfif>

<cfif IsDefined('FORM.update_button.y')>
  <cfquery datasource="#db#">
  UPDATE TextbookSurvey
  SET PrimarySubjectID = '#FORM.PrimarySubjectID#',
      SecondarySubjectID = '#FORM.SecondarySubjectID#',
      TertiarySubjectID = '#FORM.TertiarySubjectID#',
      Grade1 = '#FORM.Grade1#',
      Grade2 = '#FORM.Grade2#',
      Series = '#FORM.Series#',
      Cpyrght = '#FORM.Copyright#',
      ISBN = '#FORM.ISBN#',
      Publisher = '#FORM.Publisher#',
      Updated = #FORM.Updated#
  WHERE TextbookID = '#FORM.TextbookID#'
  </cfquery>
    <cfset sHeaderMessage="The textbook information has been updated." />
  
<cfelseif IsDefined('FORM.confirm_button.y')>
  <cfquery datasource="#db#">
  DELETE FROM TextbookSurvey
  WHERE TextbookID = '#FORM.TextbookID#'
  </cfquery>
 <cflocation url="textbook_list.cfm?SchoolID=#getSalutation.s_SchoolID#">   
  
<cfelseif IsDefined('FORM.cancel_button.y')>
  <cfset sHeaderMessage="The operation was cancelled. The information was not deleted." />
</cfif>

<cfquery datasource="#db#" name="qTextbookDetails">
  SELECT ts.TextbookID AS ts_TextbookID, ts.CountyID AS ts_CountyID, ts.Grade1 AS ts_Grade1, ts.Grade2 AS ts_Grade2, ts.PrimarySubjectID AS ts_PrimarySubjectID, ts.SecondarySubjectID AS ts_SecondarySubjectID, ts.TertiarySubjectID AS ts_TertiarySubjectID, ts.Series AS ts_Series, ts.Cpyrght AS ts_Cpyrght, ts.ISBN AS ts_ISBN, ts.Publisher AS ts_Publisher, ts.SchoolID AS ts_SchoolID, ts.Updated AS ts_Updated, s.SchoolID AS s_SchoolID, s.SchoolName AS s_SchoolName, sp.PrimarySubject AS sp_PrimarySubject, ss.SecondarySubject AS ss_SecondarySubject, st.TertiarySubject AS st_TertiarySubject, sp.PrimarySubjectID AS sp_PrimarySubjectID, ss.SecondarySubjectID AS ss_SecondarySubjectID, st.TertiarySubjectID AS st_TertiarySubjectID, c.CountyID AS c_CountyID, c.County AS c_County, go.Grade AS go_Grade, gt.Grade AS gt_Grade, go.GradeID AS go_GradeID, gt.GradeID AS gt_GradeID
  
	FROM TextbookSurvey AS ts
	LEFT JOIN SubjectCategoryPrimary AS sp ON ts.PrimarySubjectID = sp.PrimarySubjectID
	LEFT JOIN SubjectCategorySecondary AS ss ON ts.SecondarySubjectID = ss.SecondarySubjectID 
	LEFT JOIN SubjectCategoryTertiary AS st ON ts.TertiarySubjectID = st.TertiarySubjectID
	LEFT JOIN Grades1 AS go ON ts.Grade1 = go.GradeID
	LEFT JOIN Grades2 AS gt ON ts.Grade2 = gt.GradeID
	INNER JOIN School AS s ON ts.SchoolID = s.SchoolID
	INNER JOIN County AS c ON ts.CountyID = c.CountyID

    WHERE ts.TextbookID = '#URL.TextbookID#'
</cfquery>

<cfquery datasource="#db#" name="qSchool">
SELECT s.SchoolName AS s_SchoolName, s.SchoolID AS s_SchoolID, s.SchoolOpen AS s_SchoolOpen
	FROM School AS s
	WHERE s.SchoolOpen <> 0 
	ORDER BY s.SchoolName
</cfquery>

<cfquery datasource="#db#" name="qGradeOne">
SELECT go.Grade AS go_Grade, go.GradeID AS go_GradeID
	FROM Grades1 AS go
	ORDER BY go.GradeID
</cfquery>

<cfquery datasource="#db#" name="qGradeTwo">
SELECT gt.Grade AS gt_Grade, gt.GradeID AS gt_GradeID
	FROM Grades2 AS gt
	ORDER BY gt.GradeID
</cfquery>

<cfquery datasource="#db#" name="qPrimarySubject">
SELECT sp.PrimarySubject AS sp_PrimarySubject, sp.PrimarySubjectID AS sp_PrimarySubjectID
	FROM SubjectCategoryPrimary AS sp
	ORDER BY sp.PrimarySubjectID
</cfquery>

<cfquery datasource="#db#" name="qSecondarySubject">
SELECT ss.SecondarySubject AS ss_SecondarySubject, ss.SecondarySubjectID AS ss_SecondarySubjectID
	FROM SubjectCategorySecondary AS ss
	ORDER BY ss.SecondarySubjectID
</cfquery>

<cfquery datasource="#db#" name="qTertiarySubject">
SELECT st.TertiarySubject AS st_TertiarySubject, st.TertiarySubjectID AS st_TertiarySubjectID
	FROM SubjectCategoryTertiary AS st
	ORDER BY st.TertiarySubjectID
</cfquery>


<cfif IsDefined('FORM.delete_button.y')>
  <cfoutput>
    <form action="#CGI.SCRIPT_NAME#" method="post">
	  <table>
	    <tr>
		  <td>
		    <img src="images/spacer.gif" height="15" />
		  </td>
		</tr>
		<tr>
		  <td>
		    Do you really want to delete this textbook?
			<input type="hidden" name="TextbookID" value="#URL.TextbookID#" />
			<input type="image" name="confirm_button" src="images/delete.gif" />
			<input type="image" name="cancel_button"  src= "images/doNotDelete.gif" />
		  </td>
		</tr>
	  </table>
	</form>
  </cfoutput>

<cfelse>

	<cfoutput query="qTextbookDetails">
 <form action="#CGI.SCRIPT_NAME#" method="post">
    <table width="610">
      <tr>
  	    <td class="ltturq" colspan="10">School:</td>
	  </tr>
      <tr>
	    <td class="turqblue">
		  #qTextbookDetails.s_SchoolName#		</td>
	  </tr>
      <tr>
		<td>
		  <img src="images/spacer.gif" height="15" />		</td>
	  </tr>
      	  <tr>
	    <td class="ltturq"><cfif IsDefined('FORM.edit_button.y')>Please select a subject category and, if appropriate, subcategories for this book:<cfelse>Subject:</cfif></td>
	  </tr>
      <tr>
	    <td class="turqblue">
		<cfif IsDefined('FORM.edit_button.y')>
		  <select name="PrimarySubjectID">
		    <cfloop query="qPrimarySubject">
			  <option value="#qPrimarySubject.sp_PrimarySubjectID#"<cfif qTextbookDetails.ts_PrimarySubjectID EQ qPrimarySubject.sp_PrimarySubjectID> selected</cfif>>#qPrimarySubject.sp_PrimarySubject#</option>
			</cfloop>
		  </select>
		  <cfelse>
 	      #qTextbookDetails.sp_PrimarySubject#<cfif len(qTextbookDetails.ss_SecondarySubjectID) AND #qTextbookDetails.ss_SecondarySubject# NEQ "Null"> - #qTextbookDetails.ss_SecondarySubject#</cfif><cfif len(qTextbookDetails.ts_TertiarySubjectID) AND #qTextbookDetails.st_TertiarySubject# NEQ "Null"> - #qTextbookDetails.st_TertiarySubject#</cfif> 
		</cfif>		</td>
	  </tr>
      <tr>
	    <td class="turqblue">
		<cfif IsDefined('FORM.edit_button.y')>
		  <select name="SecondarySubjectID">
		    <cfloop query="qSecondarySubject">
			  <option value="#qSecondarySubject.ss_SecondarySubjectID#"<cfif qTextbookDetails.ts_SecondarySubjectID EQ qSecondarySubject.ss_SecondarySubjectID> selected</cfif>>#qSecondarySubject.ss_SecondarySubject#</option>
			</cfloop>
		  </select>
		 </cfif>		</td>
	  </tr>
      <tr>
	    <td class="turqblue">
		<cfif IsDefined('FORM.edit_button.y')>
		  <select name="TertiarySubjectID">
		    <cfloop query="qTertiarySubject">
			  <option value="#qTertiarySubject.st_TertiarySubjectID#"<cfif qTextbookDetails.ts_TertiarySubjectID EQ qTertiarySubject.st_TertiarySubjectID> selected</cfif>>#qTertiarySubject.st_TertiarySubject#</option>
			</cfloop>
		  </select>
		 </cfif>		</td>
	  </tr>
	  <tr>
		<td>
		  <img src="images/spacer.gif" height="15" />		</td>
	  </tr>
      <tr>
	    <td class="ltturq"><cfif IsDefined('FORM.edit_button.y')>Please select the grade(s) this book is appropriate for:<cfelse>Grade(s):</cfif></td>
	  </tr>
      <tr>
	    <td class="turqblue">
		<cfif IsDefined('FORM.edit_button.y')>
		  <select name="Grade1">
		    <cfloop query="qGradeOne">
			  <option value="#qGradeOne.go_GradeID#"<cfif qGradeOne.go_GradeID EQ qTextbookDetails.ts_Grade1> selected</cfif>>#qGradeOne.go_Grade#</option>
			</cfloop>
		  </select>
		  <cfelse>
 		  #qTextbookDetails.go_Grade#
		</cfif>	    </td>
	  </tr>
      <tr>
	    <td class="turqblue">
		<cfif IsDefined('FORM.edit_button.y')>
			 <select name="Grade2">
		    <cfloop query="qGradeTwo">
			  <option value="#qGradeTwo.gt_GradeID#"<cfif qGradeTwo.gt_GradeID EQ qTextbookDetails.ts_Grade2> selected</cfif>><cfif #qGradeTwo.gt_Grade# NEQ "Null">#qGradeTwo.gt_Grade#</cfif></option>
			</cfloop>
		  </select>
		  <cfelse>
		  <cfif #qGradeTwo.gt_Grade# NEQ "Null">#qTextbookDetails.gt_Grade#</cfif>
		</cfif>	    </td>
	  </tr>
	  <tr>
		<td>
		  <img src="images/spacer.gif" height="15" />		</td>
	  </tr>
      <tr>
	    <td class="ltturq"><cfif IsDefined('FORM.edit_button.y')>Please enter the series or, if this book is teacher-prepared, state this here:<cfelse>Series:</cfif></td>
	  </tr>
      <tr>
	    <td class="turqblue">
		<cfif IsDefined('FORM.edit_button.y')>
			<input type="text" name="Series" value="#qTextbookDetails.ts_Series#" class="field" size="75" />
		<cfelse>
 		  #qTextbookDetails.ts_Series#
		</cfif>        </td>
	  </tr>
	  <tr>
		<td>
		  <img src="images/spacer.gif" height="15" />		</td>
	  </tr>
      <tr>
	    <td class="ltturq"><cfif IsDefined('FORM.edit_button.y')>Please enter the copyright year:<cfelse>Copyright:</cfif></td>
	  </tr>
      <tr>
	    <td class="turqblue">
		<cfif IsDefined('FORM.edit_button.y')>
			<input type="text" name="Copyright" value="#qTextbookDetails.ts_Cpyrght#" class="field" />
		<cfelse>
 		  #qTextbookDetails.ts_Cpyrght#
		</cfif>	    </td>
	  </tr>
	  <tr>
		<td>
		  <img src="images/spacer.gif" height="15" />		</td>
	  </tr>
            <tr>
	    <td class="ltturq"><cfif IsDefined('FORM.edit_button.y')>Please enter ISBN number:<cfelse>ISBN:</cfif></td>
	  </tr>
      <tr>
	    <td class="turqblue">
		<cfif IsDefined('FORM.edit_button.y')>
			<input type="text" name="ISBN" value="#qTextbookDetails.ts_ISBN#" class="field" />
		<cfelse>
 		  #qTextbookDetails.ts_ISBN#
		</cfif>	    </td>
	  </tr>
	  <tr>
		<td>
		  <img src="images/spacer.gif" height="15" />		</td>
	  </tr>
            <tr>
	    <td class="ltturq"><cfif IsDefined('FORM.edit_button.y')>Please enter a publisher:<cfelse>Publisher:</cfif></td>
	  </tr>
      <tr>
	    <td class="turqblue">
		<cfif IsDefined('FORM.edit_button.y')>
			<input type="text" name="Publisher" value="#qTextbookDetails.ts_Publisher#" class="field" size="75" />
		<cfelse>
 		  #qTextbookDetails.ts_Publisher#
		</cfif>	    </td>
	  </tr>
	  <tr>
		<td>
		  <img src="images/spacer.gif" height="15" />		</td>
	  </tr>
	  <tr>
	    <td class="turqblue">
          <input type="hidden" name="TextbookID" value="#URL.TextbookID#" />
          <input type="hidden" name="Updated" value="#CreateODBCDateTime(Now())#" />
		  <cfif IsDefined('FORM.edit_button.y')>
		    <input type="image" name="update_button" src="images/update.gif" />
		  <cfelse>
		  <input type="image" name="edit_button" src="images/edit.gif" />
		  </cfif>	    </td>
	  </tr>
	  <tr>
	    <td>
	 	  <input type="image" name="delete_button" src="images/delete.gif" />	    </td>
	  </tr>
    </table>
  </form>
  	</cfoutput>
	
	</cfif>
<cfinclude template="/textbooks/footer.cfm" />
 
I'm wondering here about where you're communcating the value of sHeaderMessage. I see it being set initially and then possibly changed in two if statements, but I don't see it being output. Are you doing that in the included "/textbooks/header.cfm"? If so, that's your problem. It's already displayed before you reset it in the other two if statements. Move your include statement below your if statements.
 
Hi Eric -

Oh, I wish that was it! but the sHeaderMessage is output here:

<cfinclude template="/textbooks/header.cfm" />

in the "header.cfm" document.

I gave up on trying to get the message to show that way, and instead used the <cfif> to display the appropriate messages - works great!

Thanks very much, though!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top