By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,738 Members | 1,114 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,738 IT Pros & Developers. It's quick & easy.

How can I output html in a text area? Any work arounds?

P: 96
Hi guys!

First off let me explain that I know it's not possible to output html in a text area and expect it to appear rendered. =)

I'm trying to come up with a solution.

Basically, I receive from my database a field that contains html.
Something like:
Expand|Select|Wrap|Line Numbers
  1. <b>Awesome!</b> <br />
I have a text area that outputs that. The point of having that in a text area field is so that all the code that comes back from the database is placed there and will get scrollbars if the output becomes to long for the text area size.

Now, I would like to output from that field in the database the code with html rendered. So, in the example above, I'd see this in the text area:


How can I have the same "field with scrollbar" effect without using a text area?

Ideas? Thanks in advance!
Mar 13 '08 #1
Share this Question
Share on Google+
1 Reply

P: 96
Gotta love CSS!

Here's how to output rendered html into something that looks like a text area but really isn't!

I'm outputting a PHP variable in here:
Expand|Select|Wrap|Line Numbers
  1. <div style="overflow:scroll; width:100px;height:100px">
  2. <?php echo($haitashiVariable); ?>
  3. </div>
So, basically, you set the overflow CSS property to scroll and set the width and height to what you want. The result is something that looks like a text area but isn't. That means that it will output rendered html code and will automatically generate scroll bars on the side.
Mar 13 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.