Link to home
Start Free TrialLog in
Avatar of pigmentarts
pigmentartsFlag for United Kingdom of Great Britain and Northern Ireland

asked on

htmleditformat() probem

ok i had this on my SQL #HTMLCodeFormat(FORM.description)# which worked in my database the description feild has <pre>around the text</pre> put it messes the screen up in IE liek this: http://www.exquisite-jewellery.co.uk/products/11.html any idea's. new to coldfusion so take it easy
Avatar of andw928
andw928

No, use htmleditformat() not htmlcodeformat(). Two different functions.
Be sure you never use htmlcodeformat() since you are already using the <pre WRAP> blocks. The htmlCODEformat() make a second set of <pre> blocks which would override ours, and therefore wouldn't work in the browsers as before, so use <pre WRAP> with htmlEDITformat() inside of it.
Avatar of pigmentarts

ASKER

like this #htmleditformat(FORM.description)#?
Yes. Just like that that, make sure you are not using the CODEformat at all.
How did you get it to work before? When you were so happy that it worked? It worked, but then shortly after you said it didn't work, what happened?
i am not. if you look here http://www.exquisite-jewellery.co.uk/products/11.html its still pushing the box over becuase of not wraping this is my css

pre {
  white-space:pre;
  word-wrap: break-word;
  white-space:-o-pre-wrap;
  white-space:-moz-pre-wrap;
  white-space:pre-wrap;
}
 
Post the code you are using the display the text. What browser are you using? And what version? lol.
re: How did you get it to work before? When you were so happy that it worked? It worked, but then shortly after you said it didn't work, what happened?

o i have been having a probelm with try to not allow html code in a another box i have and using what you said it works don't know why but it did so am happy with that.

this is the main probelm an has been doing my head in i still think it is to do with the <pre> tags it looks fine in firefox but not ie
Post the code, because if we can't find a way to fix it with PRE, then we can always use the regular expressions I showed you in the last example. I'm still not seeing problems with my IE, but I have a very recent version.
i have a backend system i made it displays using a template to create html pages of the products created.

every product uses this page as a temaple, hope its not to long:


<cfoutput>
      <cfif product.recordCount GT 0>
            <cfloop query="product">
            <table width="100%"  border="0">
            <!-- Start shopping cart form -->
                  <form  action="http://ww9.aitsafe.com/cf/add.cfm" method="post">
                        <input type="hidden" name="return" value="www.exquisite-jewellery.co.uk" />
                        <input type="hidden" name="userid" value="#malsId#" />
                        <input type="hidden" name="product[]" value="#name# " />
                        <cfscript>
                              if(salePrice GT 0) {
                                    buyPrice = #salePrice#;
                              }
                              else {
                                    buyPrice = #price#;
                              }
                        </cfscript>
                        <input type="hidden" name="productpr" value=":#LSNumberFormat(buyPrice, '_.__')#" />
                        <input name="qty" type="hidden" value="1" />
                        <h1>Product: #name#</h1>
                                <tr valign="top">
                                    <td width="90" align="center" valign="top">
                                    <!-- image -->
                                    <cfif images.RecordCount GT 0>
                                    <div align="center"></div>
                                    <cfloop query="images"><!-- loop all images till EOF -->
                                          <div align="center"><a href="../largeImage.cfm?image=#imageId#" onclick="window.open(this.href); return false" onkeypress="window.open(this.href); return false"><img src="../secure/images/products/thumbs/#name#.jpg" alt="#name#" border="0" /></a>
                                          <br />
                                          <a href="../largeImage.cfm?image=#imageId#" onclick="window.open(this.href); return false" onkeypress="window.open(this.href); return false"><img src="../images/enlarge-image.gif" border="0" /><br />
                                          </a><a href="../largeImage.cfm?image=#imageId#" onclick="window.open(this.href); return false" onkeypress="window.open(this.href); return false">enlarge image</a> </div>
                                    </cfloop>
                                    <div align="center">
                                            <!-- end loop -->
                                            <cfelse>
                                            <!-- else no image to to dplay -->
                                      </div>
                                    <p align="center"><img src="../images/default.gif" alt="No Image available" /></p>
                                    </cfif>
                                    </td>
                                    
                                    
                                    
                                    <td><div class="detailsbox">
                                    <div class="titledetails">Description</div> #description#
                                    </div>
                                    
                                    
                                    <cfif price GT 0>
                                          <p>
                                                <cfif retailPrice GT 0>Retail Price: &pound;#LSCurrencyFormat(val(retailPrice), "none")#<br /></cfif>
                                                Price: <cfif salePrice GT 0><span class="crossout">&pound;#LSCurrencyFormat(val(price), "none")#</span><br />Sale Price: &pound;#LSCurrencyFormat(val(salePrice), "none")#<cfelse>&pound;#LSCurrencyFormat(val(price), "none")#</cfif></p>
                                    <cfelse>
                                          <p>This product is not available for purchase online. Please call us for more information.</p>
                                    </cfif>
                                    
                                    <div class="detailsbox">
                        <!-- options -->
                        <cfloop query="options">
      
                              <cfinvoke component="#component#" method="getValues" returnvariable="getValues">
                                 <cfinvokeargument name="optId" value="#optionId#">
                              </cfinvoke>
                              <cfif getValues.RecordCount GT 0>
                              <div class="titledetails">Product Options</div>
                              <p>This item from Exquisite Jewellery has product options which need to be selected before adding to your cart please select from drop down list below thanks.<br />
                                    <br />
                                    <strong>#name#: </strong>
                                    <cfloop query="getValues">
                                            <cfif optionPrice GT 0>
                                                    <cfset pricePresent = TRUE>
                                                  <cfelse>
                                                    <cfset pricePresent = FALSE>
                                              </cfif>
                                      </cfloop>
                                    
                                    <cfscript>
                                          if(pricePresent IS TRUE) {
                                                selectName = "productpr";
                                          }
                                          else {
                                                selectName = "product[]";
                                          }
                                    </cfscript>
      
                                    <select name="#selectName#" size="1">
                                      <cfloop query="getValues">
                                              <cfscript>
                                                if(getValues.optionPrice GT 0) {
                                                      optValue = '#getValues.value# :#LSNumberFormat(getValues.optionPrice, "_.__")#';
                                                      optName = '#getValues.value# £#LSCurrencyFormat(val(getValues.optionPrice), "none")#';
                                                }
                                                else if(pricePresent IS TRUE) {
                                                      optValue = '#getValues.value# :#LSNumberFormat(product.price, "_.__")#';
                                                      optName = '#getValues.value#';
                                                }
                                                else {
                                                      optValue = '#getValues.value#';
                                                      optName = '#getValues.value#';
                                                }
                                          </cfscript>
                                              <option value="#optValue#">#optName#</option>
                                        </cfloop>
                                      </select>
                              </p>
                                    </cfif>
                              
                        </cfloop>
                         </div>
                        <p><input type="submit" value="Buy now!"></p>
                  </form>
                                    
                                    
                                    <td align="center" valign="top"></td>
                                <td align="center" valign="top"></tr>
                          </table>

            </cfloop>
      <cfelse>
            <p>This product no longer exists.</p>
      </cfif>
</cfoutput>


the sql is --------------------------------


<cffunction name="addProduct" hint="try adding a product">
      <cfscript>
            success = FALSE;
            if (len(FORM.metaKeywords) LT 201) {
                  success = TRUE;
            }
            if (len(FORM.metaDescription) LT 201) {
                  success = TRUE;
            }      
            if(not IsDefined('FORM.featured')) {
                  FORM.featured = "off";
            }
            if(not IsDefined('FORM.active')) {
                  FORM.active = "off";
                  }
            if (FORM.pageName IS NOT "") {
                  productPageName = Replace(#FORM.pageName#," ","_");
            }
            else {
                  productPageName = Replace(#FORM.name#," ","_");
            }
      </cfscript>

      <cfif Success IS TRUE>
            <cfquery name="addProduct" datasource="#dbSource#">
                  INSERT INTO products (name, productCode, description, price, retailPrice, salePrice, pageName, metaKeywords, metaDescription, catId, manId, active, featured) VALUES ('#FORM.name#', '#FORM.productCode#', '#htmleditformat(FORM.description)#', '#FORM.price#', '#FORM.retailPrice#', '#FORM.salePrice#', '#productPageName#', '#FORM.metaKeywords#', '#FORM.metaDescription#', '#FORM.catId#', '#FORM.manId#', '#FORM.active#', '#FORM.featured#')
            </cfquery>
            
            <cfquery name="getLastProdId" datasource="#dbSource#" maxrows="1">
                  SELECT prodId FROM products ORDER BY prodId DESC
            </cfquery>
            
            <cfscript>
                  prodId = #getLastProdId.prodId#;
                  imageName = #getLastProdId.prodId#;
            </cfscript>
      
            <cfhttp method="get"
                  url="#productPageTemplate#?prodId=#prodId#">
            </cfhttp>
            <cfset productPageContent = #cfhttp.FileContent#>
            
            <cffile action="write"
                        output="#productPageContent#"
                        file="#productPageLocation##productPageName#.html"
                        nameconflict="overwrite">
      
      </cfif>
      <cfset Session.success = "You have successfully added the product">
</cffunction>
in the database the description looks like this <pre>some text</pre>

now its find when you don't type to long and alway start a new line after a few words put my screen page messes up if not
Well change the description from <pre> to <pre wrap="wrap">, and then tell me if that works.
where i have set the <pre> can you see?
You know what, instead of storing the <pre> in the database, you should instead use it in the .cfm file before and after display the text. Would be much easier. And then change <pre> to <pre wrap="wrap">
                           <td><div class="detailsbox">
                              <div class="titledetails">Description</div> <pre wrap="wrap">#description#</pre>
                              </div>
sounds better, but i really can not find where it is putting the <pre> i am still looking
Lol, ok, once you find it try it, if it still won't work, then we can always go back and use regular expressions to do the same job.
the guy who wrote this part with the <pre> tag is away i really want not find where it add it is there anyway the database could be adding it we are using mysql? the only thing i have foudn that looks intresting is this...... but i don't think thats did lol

<cfif IsDefined('prodId')>
      <cfquery name="getProduct" datasource="#dbSource#">
            SELECT * FROM products WHERE prodId = '#prodId#'
      </cfquery>
      <cfloop query="getProduct">
            <cfscript>
                  prodId = #prodId#;
                  name = #name#;
                  productCode = #productCode#;
                  description = REReplace(description,"<[^>]*>","","ALL");
                  price = #price#;
                  retailPrice = #retailPrice#;
                  salePrice = #salePrice#;
                  active = #active#;
                  featured = #featured#;
                  pagename = #pagename#;
                  metaDescription = #metaDescription#;
                  metaKeywords = #metaKeywords#;
                  catId = #catId#;
            </cfscript>
      </cfloop>
<cfelse>
      <cfscript>
            prodId = "";
            name = "";
            productCode = "";
            description = "";
            price = "";
            retailPrice = "";
            salePrice = "";
            active = "on";
            featured = "off";
            pagename = "";
            metaDescription = "";
            metaKeywords = "";
            catId = #FORM.catId#;
      </cfscript>
</cfif>
lol you can tell am not english let me write that again slower:

the guy who wrote this part of the system with the <pre> tag is away i really want to find where it is. could the database be adding it at its end, we are using mysql?
nope not in the database
It doesn't look like the database is adding it. How about when displaying the data, use regex right before it, and then change #description# to #newdescription#, do this:

<cfset newdescription = htmleditformat(description)>
<cfset newdescription = replace(newdescription, '#chr(9)#', '&nbsp;&nbsp;&nbsp;&nbsp;', 'all')>
<cfset newdescription = replace(newdescription, ' ', '&nbsp;', 'all')>
<cfset newdescription = replace(newdescription, '#chr(10)#', '<br />', 'all')>

<td><div class="detailsbox">
                        <div class="titledetails">Description</div> #newdescription#
                              </div>
doing the following still puts the <pre> tags in

<cfset newdescription = htmleditformat(description)>
<cfset newdescription = replace(newdescription, '#chr(9 #', '&nbsp;&nbsp;&nbsp;&nbsp;', 'all')>
<cfset newdescription = replace(newdescription, ' ', '&nbsp;', 'all')>
<cfset newdescription = replace(newdescription, '#chr(10)#', '<br />', 'all')>

<div class="titledetails">Description</div> #newdescription#

output is --------------------


<PRE>wwww  msmndkj k ksjd  kdjk s ksdjks ks ksjkk k  skdjkjjd ksdkj kskdkjs kk skdk kjsdkjk sjskdkjskj k ks ksk ksd s</PRE>

the <pre> has sliped in again
I know, you're going to have to find and remove the <pre> tags, whereever your application puts them, and then use the code I just gave you without the pre tags. Is it atleast not breaking the display in IE anymore?
it must be putting it on at this page somewher. this is the page when you add to the database:

--------------------------------------------

<cfinvoke method="checkLoggedIn" component="#component#">

<cfif IsDefined('URL.prodId') OR IsDefined('FORM.addProduct') OR IsDefined('FORM.add') OR IsDefined('FORM.update')>
      <cfif IsDefined('FORM.add') OR IsDefined('FORM.update')>
            <cfinvoke method="checkInput" component="#component#" returnvariable="errors">
            <cfif errors IS "">
                  <cfif IsDefined('FORM.add')>
                        <cfinvoke method="addProduct" component="#component#">
                        <cfinvoke method="getLastProdId" component="#component#" returnvariable="prodId">
                        <cfset Session.prodId = "#prodId#">
                  <cfelseif IsDefined('FORM.update')>
                        <cfinvoke method="updateProduct" component="#component#">
                        <cfset Session.prodId = "#FORM.prodId#">
                  </cfif>
                  <cfset Session.catId = "#FORM.catId#">
                  <cfif FORM.addOptions IS "yes">
                        <cflocation url="assign_options.cfm">
                  <cfelse>
                        <cflocation url="assign_images.cfm">
                  </cfif>
            </cfif>
      </cfif>
      <cfinclude template="objects/productVars.cfm">
      <cfinvoke method="getProductOptions" component="#component#" returnvariable="productOptions">
            <cfinvokeargument name="prodId" value="#prodId#">
      </cfinvoke>
      <cfinvoke method="getProductImages" component="#component#" returnvariable="productImages">
            <cfinvokeargument name="prodId" value="#prodId#">
      </cfinvoke>
<cfelse>
      <cflocation url="#manageProducts#">
</cfif>
<cfparam name="featured" default="off" type="string">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/secureTemplate.dwt.cfm" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<cfif IsDefined('FORM.addProduct')>
      <title>Add Product</title>
<cfelse>
      <title>Modify Product</title>
</cfif>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
      <div id="banner"><span class="loginStatus">
      <!-- InstanceBeginEditable name="loginStatus" -->
      <cfif Request.LoggedIn IS True>
            <cfoutput>Logged On : <strong>#Session.username#</strong></cfoutput>
      <cfelse>
            user : not logged in
      </cfif>
      <!-- InstanceEndEditable -->
      </span></div>
      <ul class="navBar">
      <!-- InstanceBeginEditable name="navLinks" -->
      <cfif Request.LoggedIn IS True>
            <cfinclude template="#mainMenu#">
      </cfif>
      <!-- InstanceEndEditable -->
      </ul>
      <!-- InstanceBeginEditable name="leftNav" -->
      <ul class="leftNav">
            <cfinclude template="#storeMenu#">
            <cfinclude template="#constantMenu#">
      </ul>
      <!-- InstanceEndEditable -->
      <div id="mainBody">
            <div id="content">
                  <!-- InstanceBeginEditable name="currentSection" -->
            <h1 class="currentPage">Manage Store</h1>
            <!-- InstanceEndEditable -->
                  <!-- InstanceBeginEditable name="content" -->
                  <cfoutput>
                  <cfif IsDefined('FORM.addProduct') OR IsDefined('FORM.add')>
                        <h1>Add Product</h1>
                  <cfelse>
                        <h1>Modify Product</h1>
                  </cfif>
                  
                  <cfif IsDefined('errors')>
                        <h3 class="error">ERRORS</h3>
                        <ul>
                              #errors#                  
                        </ul>
                  </cfif>
                        <p>Please enter the details of the product in the form below. Fields marked with a <span class="required">*</span> are required.</p>
                        <cfform action="#ThisPageUrl#" enctype="multipart/form-data" method="post" class="newForm">
                        
                              <fieldset>
                                    <legend>New Product Details</legend>
                                    <p><div class="labelRight"><label for="productCode">Product Code</label><br /><cfinput type="text" name="productCode" value="#productCode#" tabindex="2" size="10" /></div>
                                    <label for="name"><span class="required">*</span>Name</label><br /><cfinput type="text" name="name" tabindex="1" size="25" required="yes" value="#name#" message="A department name is required." /></p>
                                    
                                    <p><label for="description"><span class="required">*</span>Description</label><br /><textarea name="description" tabindex="3">#Description#</textarea></p>
                                    
                                    <p><div class="labelRight"><label for="salePrice">Sale Price</label><br />&pound;<cfinput type="text" name="salePrice" validate="regular_expression" pattern="[0-9]\.[0-9][0-9]" value="#LSNumberFormat(salePrice, "_.__")#" tabindex="6" size="10" required="no" /></div>
                                    <div class="labelRight"><label for="retailPrice">Retail Price</label><br />&pound;<cfinput type="text" name="retailPrice" validate="regular_expression" pattern="[0-9]\.[0-9][0-9]" value="#LSNumberFormat(retailPrice, "_.__")#" tabindex="5" size="10" required="no" /></div>
                                    <label for="Price"><span class="required">*</span>Price</label><br />&pound;<cfinput type="text" name="price" validate="regular_expression" pattern="[0-9]\.[0-9][0-9]" value="#LSNumberFormat(price, "_.__")#" tabindex="4" size="10" required="yes" message="You must enter a price for the product." /></p>
                                    
                                    <p>
                                          <div class="labelRight"><label for="featured">Active</label>
                                          <cfif active IS "on">
                                                <cfinput type="checkbox" checked="yes" name="active" tabindex="9" />
                                          <cfelse>
                                                <cfinput type="checkbox" checked="no" name="active" tabindex="9" />
                                          </cfif>
                                          </div>
                                          <div class="labelRight"><label for="featured">Featured</label>
                                          <cfif featured IS "on">
                                                <cfinput type="checkbox" checked="yes" name="featured" tabindex="8" />
                                          <cfelse>
                                                <cfinput type="checkbox" checked="no" name="featured" tabindex="8" />
                                          </cfif>
                                          </div>
                                          
                                          <cfif IsDefined('FORM.addProduct') OR IsDefined('FORM.add')>
                                          <cfinvoke method="getmanufacturers" component="#component#" returnvariable="manufacturers">      
                                                <label for="manufacturer"><span class="required"></span>Manufacturer</label><br />
                                                <select name="manId" tabindex="7">
                                                <cfloop query="manufacturers">
                                                      <option value="#manId#">#name#</option>
                                                </cfloop>
                                                </select>
                                          </cfif>
                                    </p>
                                    
                                    <p><label for="name">Page Name</label><br /><cfinput type="text" name="pageName" value="#pageName#" tabindex="11" size="25" required="no" /></p>
                                    <p><label for="meatDescription">Meta Description</label><br /><textarea name="metaDescription" tabindex="12" >#metaDescription#</textarea></p>
                                    <p><label for="meatKeywords">Meta Keywords</label><br /><textarea name="metaKeywords" tabindex="13">#metaKeywords#</textarea></p>
                                    
                                    
                                    <h3>Product Images</h3>
                                    <cfif productImages.RecordCount GT 0>
                                          <cfloop query="productImages">
                                                <img src="images/products/#name#.jpg" alt="#name#" />
                                          </cfloop>
                                    <cfelse>
                                          <p class="error">You have not yet uploaded any pictures for this product.</p>
                                    </cfif>
                                    
                              
                                    <h3>Options</h3>
                                    <cfif IsDefined('URL.prodId') AND productOptions.RecordCount GT 0>
                                          <cfinclude template="objects\productOptions.cfm">
                                    <cfelse>
                                          <p class="error">No options have been added to this product.</p>
                                    </cfif>
                                    
                                    <p><label for="options">Do you wish to add/modify options to this product? </label>
                                    <select name="addOptions" tabindex="14">
                                          <option value="no" selected>No</option>
                                          <option value="yes">Yes</option>
                                    </select>
                                    </p>
                                    
                                    
                                    <input type="hidden" name="catId" value="#catId#" />  
                                    <input type="hidden" name="prodId" value="#prodId#" />
                                    <input name="existingPageName" type="hidden" value="#pageName#" />
                                    <cfif IsDefined('FORM.addProduct') OR IsDefined('FORM.add')>
                                          <input type="submit" name="add" size="15" value="Add Product & Continue" />
                                    <cfelse>
                                          <input type="submit" name="update" size="15" value="Update Product &amp; Continue" />
                                    </cfif>
                              </fieldset>
                        </cfform>
                        <p><a href="#manageProducts#?catId=#catId#">&lt; &lt; Back to Product List</a></p>
                        </cfoutput>
It's not there, it has to be somewhere before it is displayed.
Either that, or you have an htmlcodeformat() somewhere.
htmlcodeformat() only appears in the sql and i changed that like you said
ASKER CERTIFIED SOLUTION
Avatar of andw928
andw928

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
DONE! yes thats the reason got there in the end many thanks for all your help, sure i'll be back.