The Value of Description field in Coldfusion does not go away

sglee
sglee used Ask the Experts™
on
Description FieldTable in MS ACCESSHi,
 I have CFM page where the description field (TEXTAREA) displays old value even after I replaced it with new text. As seen on the screenshot below, the new value that I assigned to Description field shows the new text and immediately followed by old text.

Old Value: "VERY CLEAN! Conestoga Kit, Air Ride Slider, 48x96 Steel Flatbed, 22.5 11 r Tires & Wheels, 50% Brakes & Tires"
New Value "Swing doors, spring ride slider, 22.5 low pro tires, 3 side doors (curb side) spring ride slider".

Here is my CF code:

 <td colspan="2"><b>Description:
                           </td> </tr> <tr>  <td colspan="2"> <TEXTAREA NAME=Description ROWS=5 COLS=33 WRAP="VIRTUAL"><cfoutput>#GetFeaturedItems.Description#</cfoutput></TEXTAREA></td>   </tr>

When I open the table in MS ACCESS, I see the new text in Description field and I do not see old text. I don't know where this old text comes from.
One thing that is very strange is that "VERY CLEAN! Conestoga Kit, Air Ride Slider, 48x96 Steel Flatbed, 22.5 11 r Tires & Wheels, 50% Brakes & Tires" is in two other records on the table along with different Item No and this is what is repeating.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2015

Commented:
If you dump the raw query used to populate the text field, does it contain both the old + new text?
ie <cfdump var="#GetFeaturedItems#">

Author

Commented:
Here is the dump and item listing on the webpage along with MS access records.
CFDumpitem listingMS Access Inventory Table
Most Valuable Expert 2015

Commented:
Are you using a CFFORM or regular form?

Can you dump the individual values right before the textarea (but not inside it).  Use HTMLEditFormat to be sure it displays any hidden characters:

<td colspan="2">
<!--- debugging code --->
 Value: <cfoutput>#HTMLEditFormat(GetFeaturedItems.Description)#</cfoutput>

<TEXTAREA NAME=Description ROWS=5 COLS=33 WRAP="VIRTUAL">cfoutput>#GetFeaturedItems.Description#</cfoutput></TEXTAREA></td>
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Author

Commented:
Here it is:CFDump
Most Valuable Expert 2015

Commented:
Hm... that looks like the text IS part of the records.

Create a totally separate debug page with only the cfquery. Output the data for each row (no tables or extra html). That should confirm whether the text is actually part of the record or it just seems that way in the html:

<cfoutput query="GetFeaturedItems">
<hr>#TheIDColumnForTheTable# ||
<pre>#HTMLEditFormat(GetFeaturedItems.Description)#</pre>
</cfoutput>

Author

Commented:
I am getting an error when I run the code above:
"Variable THEIDCOLUMNFORTHETABLE is undefined. "
Most Valuable Expert 2015

Commented:
That's just a placeholder for the query column containing the record id.  :) Now I see it's literally named "ID", so just replace it with #ID#

Author

Commented:
I ran the following code on a separate CFM page:
            <CFQUERY NAME="GetCategory" datasource="CCT">
                  SELECT      *
                     FROM         Category
            ORDER BY Category
            </CFQUERY>
            <CFQUERY NAME="GetFeaturedItems" datasource="CCT">
                  SELECT      Inventory.* ,  Category.Category
                     FROM         Inventory, Category
                WHERE    Inventory.CategoryID = Category.ID
            </CFQUERY>
<cfoutput query="GetFeaturedItems">
 <hr>#ID#
 <pre>#HTMLEditFormat(GetFeaturedItems.Description)#</pre>
 </cfoutput>


24 Swing doors, spring ride slider, 22.5 low pro tires, 3 side doors (curb side) spring ride slider
25 VERY CLEAN! Conestoga Kit, Air ride slider, 48x96 steel flatbed, 22.5 11r tires & wheels, 50% brakes & tires
26 Swing doors, spring ride slider, 22.5 low pro tires, 3 side doors (curb side) spring ride slider.
27 Please call for the best deal!
28 VERY CLEAN! Conestoga Kit, Air Ride Slider, 48x96 Steel Flatbed, 22.5 11 r Tires & Wheels, 50% Brakes & Tires
Most Valuable Expert 2015

Commented:
Are those the same records in the screen shots?  The id's are different, so I'm not sure where record begins and ends without the "||" and "<hr>".

Author

Commented:
Sorry I dumped all records from the table. Here are the records IDs and corresponding Item No shown on EE ID: 40924890
      Record ID  ItemNo
       26               1012
      27               1015
      28               1016

 26     Swing doors, spring ride slider, 22.5 low pro tires, 3 side doors (curb side) spring ride slider.
 27     Please call for the best deal!
 28     VERY CLEAN! Conestoga Kit, Air Ride Slider, 48x96 Steel Flatbed, 22.5 11 r Tires & Wheels, 50% Brakes & Tires
Most Valuable Expert 2015

Commented:
Ok, then that confirms the text really isn't part of the db record, and it's likely something to do with your output code.   I'm trying to avoid you having to post the code for the entire page, so first ... are you using a "grouped" cfoutput query="...." anywhere in that page?   Edit: Or maybe nested <cfoutput> tags?
Most Valuable Expert 2015

Commented:
Hm... curious, looking at the screen shots the first table seems to contains all 3 descriptions (26,27,28), the 2nd one contains (27,28) and the last one contains only (28).

Author

Commented:
Here is the code:

Here is CFM page in a nutshell:

<CFFORM name="form1" Method=POST ACTION="ListInventory.cfm">
<tr>
<td>
<table width=880 border=0 cellpadding=0 cellspacing=0 valign="middle" align="center" style="border:1px outset black;">
          <td bgcolor="ffffff" align="left">&nbsp;&nbsp;&nbsp;<font FACE="verdana,arial,helvetica" size=2>
                  <SELECT NAME="CategoryID">
                    <OPTION VALUE="0"></OPTION>
                  <CFOUTPUT query="GetCategory">
                  <OPTION VALUE="#ID#">#Category#</OPTION>
                  </CFOUTPUT>
                  </SELECT>
            </TD>
        <TD bgcolor="ffffff" colspan=5 align=center>
                  <INPUT TYPE=SUBMIT Name"Submit_Btn" VALUE="List Inventory">
</table>

</CFFORM>
</div>

            <CFQUERY NAME="GetFeaturedItems" datasource="CCT">
                  SELECT      Inventory.* ,  Category.Category
                     FROM         Inventory, Category
                WHERE   Inventory.Featured = 'Y'
                AND Inventory.CategoryID = Category.ID
            </CFQUERY>
<div>

<TABLE width=880 border="0" cellpadding="1" cellspacing="1" align="center" >
       <cfoutput query="GetFeaturedItems">

         <td align="center" >
         <table border="0" Style="border:2px outset black;">
         <tr>
                 <TD align="center" bgcolor="DDDDDD">
                      <table width="100%" border="0" align="center">
                           <tr>
                           <td bgcolor="005BA4" colspan="2" align="center" height="60px" width="220px">
                         <font color="ffffff"> <B>#Title#</B></font>               
                           </td>
                           </tr>
                           <tr>
                           <td colspan="2" align="center" bgcolor="FFFFFF"><img border="0" width = "220" height="120" src="http://www.domain.com/ImageUpload/#pic1#"><BR>
                           </td>
                           </tr>
                           <tr>
                           <td>
                            <b>Condition:&nbsp;&nbsp;
                              </td>
                           <td><font color="990000">#Condition#</font></b>

                           <td><b>Item No:</b>
                           </td>
                           <td>#ItemNo#
                           </td>
                           </tr>
                             <tr>
                           <td><b>Price:</b>
                           </td>
                           <td>#numberformat(Price, "$(,.00)")#
                           </td>
                           </tr>
                           <tr>
                           <td colspan="2"><b>Description:</b><BR>
<cfoutput>#HTMLEditFormat(GetFeaturedItems.Description)#</cfoutput>
                           </td>
                           </tr>
                           <tr>
                           <td colspan="2"> <TEXTAREA NAME=Description ROWS=5 COLS=33 ><cfoutput>#Description#</cfoutput></TEXTAREA>
                           </td>
                           </tr>
                           <tr>
                           <td colspan="2" align="center"><img src="/images/img_call.jpg" border="0">
                           </td>
                           </tr>            
                  </table>
             </TD>
          </tr>
         </table>
         </td>
<cfif GetFeaturedItems.currentRow mod 3 eq 0>
  <cfif GetFeaturedItems.currentRow gt 1>
     </tr>
  </cfif>
     <tr>
  </cfif>
         </cfoutput>
      <TR><TD >&nbsp;&nbsp;&nbsp;</TD></TR>
      <tr>
            <!--<TD>&nbsp;&nbsp;&nbsp;</TD>-->
          <td align="center"></td>
            
      </tr>
      <tr>
            <TD colspan=3>&nbsp;&nbsp;&nbsp;</TD>
      </tr>
      <!--<tr>
      <td colspan="3"><br />
      </td>
      </tr>-->
</table>
Most Valuable Expert 2015
Commented:
Ohh.... wait a minute.  I think it's the extra <cfoutput> tags.  

Since you're already inside a cfoutput loop, when you include the extra tags around the query column, it causes the values from multiple rows to be displayed inside the textarea, similar to using a "grouped" cfoutput.  

<cfoutput query="GetFeaturedItems">
   ...
    <TEXTAREA NAME=Description ROWS=5 COLS=33 ><cfoutput>#Description#</cfoutput></TEXTAREA>
   ...
</cfoutput>

Get rid of the inner cfoutput tags and it should work fine.

      <cfoutput query="GetFeaturedItems">
            .....
            <!--- don't use cfoutput tags around the column variable --->
            <TEXTAREA NAME=Description ROWS=5 COLS=33 >#Description#</TEXTAREA>
            ...
      </cfoutput>

Author

Commented:
@agx

That was it. I had redundant <cfoutput>... </cfoutput> around  #Description#
Thank you for pointing that out. You are so good!!!
Most Valuable Expert 2015

Commented:
Yeah, it's one of those minor things that is very easy to overlook but creates some really unexpected results.  Glad I could help :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial