[SOLVED] Displaying HTML code in <textarea>

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

[SOLVED] Displaying HTML code in <textarea>

Post by voltrader »

I'm in process of writing my admin module and I would like to be able to enter strings of HTML code, which are then stored in the database.

For some reason, when I retrieve the code, and addslashes to them, they seem to get truncated.

HTML is stored in the db as so:

Code: Select all

\<a href='http://www.domain.net/click-1647300-10382409' target='_top' >
<b>some stuff</b>
</a>
<img src='http://www.domain.com/image-1647300-10382409' width='1' height='1' border='0'\>
When I retrieve it from the db using adslashes, I see this in the textarea:

<b>some stuff</b></a><img src='http://www.domain.com/image-1647300-10382409' width='1' height='1' border='0'\>'>

I'm missing the initial anchor. Any ideas what I'm doing wrong?
Last edited by voltrader on Tue Mar 29, 2005 10:56 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

how are you attaching the html to the textarea? I just use htmlentities().
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

Post by voltrader »

Ahhh - thanks. You solved my problem with that question!

I was attaching the html code in <textarea value='code'> rather than putting the code inbetween the tags.

:P
Post Reply