Inputing HTML in text area and being able to display the code without the HTML working on the page

Posted on 2007-07-24
Medium Priority
Last Modified: 2013-12-24
Hi experts,

I'm trying to  create a page in Coldfusion that inputs HTML code and displays it as text, something similar to how this experts-exchange forum works, so I don't want the HTML to actually change anything on the page but I want to be able to display it.

So my question is how do I go about doing this? I'm assuming we need to use something like HTMLCodeFormat to convert symbols to the HTML characters so they can be inputed into the database easily (I'm using access) but then how do u display them without turning it into actual HTML on the page?!
Question by:techman36
  • 3
  • 2
LVL 14

Accepted Solution

Scott Bennett earned 200 total points
ID: 19558660
you can use HTMLCodeFormat to replace the html characters before you enter it into the database. Then when you pull it out of the database and display it, you would just output it as is as it is already html escaped and surrounded by <pre></pre> tags
LVL 25

Expert Comment

by:James Rodgers
ID: 19564848
a beeter option is #htmlEditFormat(thisFile,-1)# escapes teh special char in html (<,>,%,' etc) and preserves formatting

i use this in a text area to edit text based pages (txt, cfm, html, etc) online
read file contents into a variable
<cffile action="read" file="#url.pth#\#URL.file#" variable="thisFile">
display as editable text
<textarea name="fileContent" style="font-family:verdana; font-size:11px; height:500px; width:600px;">#htmlEditFormat(thisFile,-1)#</textarea>
LVL 14

Expert Comment

by:Scott Bennett
ID: 19566592
If you are going to put the code in a textarea box then you should use htmlEditFormat as jester suggests but from your question it seems like you want to just display it inline with the forum text as EE does. In this case I would recomend using HTMLCodeFormat
Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.


Author Comment

ID: 19568428
Ok so HTMLCodeFormat sounds great the only issue is that I want to allow the user to update their inputs, when I repopulate the text area so the user can edit their inputs, the <PRE> and </PRE> tags apear around the data. How do I remove these from both ends? Any simple way to do this?!
LVL 25

Expert Comment

by:James Rodgers
ID: 19568613
thats why i suggested the #htmlEditFormat(thisFile,-1)# option, the reason i use this is to avoid the <pre> tag being constanly appended to the file
LVL 14

Expert Comment

by:Scott Bennett
ID: 19569217
oh ok if you are going to allow them to edit their posts, then use htmleditformat when you put it into the database, then surround each post by <pre> tags when you want to display it and don't use them when you want to edit it in a textarea field.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
What You Need to Know when Searching for a Webhost Provider
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
Suggested Courses
Course of the Month16 days, 1 hour left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question