Display HTML in Textview

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TryAgain2
Forum Newbie
Posts: 17
Joined: Tue Jun 12, 2007 10:05 pm

Display HTML in Textview

Post by TryAgain2 »

Is there a way to display an HTML string correctly in a Textview?

Code: Select all

echo    "<td width='139' height='428' valign='top'><textarea name='textarea2' rows='32' readonly='readonly'>$headwordList</textarea></td>";
This displays the string in $headwordList with all of its HTML tags showing, like this:
<font color = black>ball 1 1</font><br /><font color = black>and 1 1</font><br /><font color = yellow>butt 9 1</font><br />
What I want is for it to display a coloured list.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Please explain.
TryAgain2
Forum Newbie
Posts: 17
Joined: Tue Jun 12, 2007 10:05 pm

Post by TryAgain2 »

Instead of seeing:

<font color = blue>this 1 200</font><br />

I want:

this 1 200
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

That's not really a "list," but I see what you're saying.

I think what you're looking for is a WYSIWYG text editor for your page. Look into FCKeditor.
TryAgain2
Forum Newbie
Posts: 17
Joined: Tue Jun 12, 2007 10:05 pm

Post by TryAgain2 »

The text is generated with a php script, so an editor won't help (unless I completely misunderstood you). If $headwordList is echoed outside of a Textview then it shows as expected. Within the Textview it displays with tags.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Right. Umm... I think you may have misunderstood me.

We don't call textareas "Textview" because they don't exist for viewing, they exist for editing. The "expected" behavior of a textarea is to display the actual text, not the rendered version of it.

Do you want it to be editable or just to be viewed?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Since the textarea is readonly, why not simply not use it?
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Yeah. If you're trying to get scrollbars by using <textarea>, the same effect can be achieved with a little CSS; google: "css overflow"
TryAgain2
Forum Newbie
Posts: 17
Joined: Tue Jun 12, 2007 10:05 pm

Post by TryAgain2 »

The "textarea" that I drop onto layout in Dreamweaver can be set to readonly or editable. I wanted to use it for displaying text generated by PHP script. Ambush hit it on the head; I want the scrollbars. CSS gives me a headache (notice I used the depreciated <font color> -I couldn't work out the equivalent in css), but I'll look up css overflow as suggested.

The textarea would have been fine, exept that it displays tags.
Styx
Forum Newbie
Posts: 9
Joined: Thu Jun 21, 2007 5:37 am

Post by Styx »

Then the css is really what you're looking for unless you want to be messy and use something like iframe.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

TryAgain2 wrote:The "textarea" that I drop onto layout in Dreamweaver can be set to readonly or editable. I wanted to use it for displaying text generated by PHP script. Ambush hit it on the head; I want the scrollbars. CSS gives me a headache (notice I used the depreciated <font color> -I couldn't work out the equivalent in css), but I'll look up css overflow as suggested.

The textarea would have been fine, except that it displays tags.
A textarea wouldn't even have been semi-fine. You need to understand that HTML tags all have a purpose and it's not about how the data is displayed, but what data is being displayed. Textareas exist to enable multi-line input, and the readonly attribute is there to let your users know that even if they try to alter it, it won't matter because you've already saved it in the back-end. Anyone (developers, especially) can remove the readonly attribute and modify it, but we put it there as an indicator, not a rule.

Just like the "list" you are making. Line breaks (<br />) don't exist to list items, but to end lines abruptly when necessary. Lists are made using list tags (<ul>, <ol>, etc.) and list item tags (<li>, etc.). Every tag that we have in HTML has a meaning, and the few that "don't" (span and div) exist for anything that is not already defined as a tag. Using tags correctly will make your HTML make more sense, be more friendly to handicapped users, and can easily improve your search engine ranking, as every reputable search engine uses HTML mark-up and it's actual meanings to decipher important keywords, content, and relevance. Also, using proper CSS will decrease file-sizes, which is considered friendlier by Google (not sure about others).

I'd suggest you look into CSS and maybe into a list of HTML tags and their purposes.
TryAgain2
Forum Newbie
Posts: 17
Joined: Tue Jun 12, 2007 10:05 pm

Post by TryAgain2 »

Yes, I don't know about making web pages. I'll try to find time to learn or find someone capable.

The page can be seen here: http://www.usingenglish.com/members/HWLevelAnalyzer/

It's my first PHP page. Any specific comments on improving it are welcome and appreciated.
Post Reply