471,336 Members | 1,262 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,336 software developers and data experts.

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

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
1 2348
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.

Similar topics

2 posts views Thread by Bill Sneddon | last post: by
13 posts views Thread by Stumped and Confused | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.