Viewing HTML code in a textarea

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
fatfishmatt
Forum Newbie
Posts: 5
Joined: Thu Aug 25, 2005 9:43 pm

Viewing HTML code in a textarea

Post by fatfishmatt »

I'm trying to pull HTML code into a form textarea however I actually want the code to be displayed and not the formatting.

i.e. <font color="#FF0000;">Hello World</font> needs to be displayed as <font color="#FF0000;">Hello World</font> and not red text that says Hello World.

Thanks in Advance
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

If it's in a textbox you don't really need to do anything extra....
fatfishmatt
Forum Newbie
Posts: 5
Joined: Thu Aug 25, 2005 9:43 pm

Post by fatfishmatt »

I've developed a CMS with a WYSIWYG editor so consider the following scenario:

If I want to write some text formatting on my site to make a certain word red I highlight the word and the WYSIWIG editor will wrap the HTML code into the textbox. Within the text box I'll then see <font color="red">Hello World</font>

I then save the page and this gets written to my site...... fine and dandy.

The problem is then when I want to edit my text again. When I click the text editing tool the textarea pops up with 'Hello World' in red and not Hello world with the HTML font tag wrapped around it. Because my save function reads the textarea and sees no HTML formatting when it writes back to the site again the formatting is neglected.

So....... the problem being is that when I bring up the text to edit I need the textarea to display all HTML tags.

Again thanks in advance...
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

I'm not sure I understand... your html formatting isn't getting saved to the database?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Code: Select all

htmlentities();
html_entity_decode();
fatfishmatt
Forum Newbie
Posts: 5
Joined: Thu Aug 25, 2005 9:43 pm

Post by fatfishmatt »

No.... it's getting saved fine.

The problem arises when I try to edit the text that I've just formatted. A pop-up window appears and loads the text into a textarea. This text then displays the formatting which is not what I wat it to do. It needs to display the actual HTML code

i.e. <font color="red">Hello World</font> needs to be displayed exactly as is, HTML tags and all. I don't want it to display red text that reads 'Hello World'
fatfishmatt
Forum Newbie
Posts: 5
Joined: Thu Aug 25, 2005 9:43 pm

Post by fatfishmatt »

Thanks astions...

htmlentities(); did the trick!
Post Reply