Page 1 of 1

Display HTML in Textview

Posted: Sat Jun 16, 2007 9:40 am
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.

Posted: Sat Jun 16, 2007 9:43 am
by feyd
Please explain.

Posted: Sat Jun 16, 2007 10:53 am
by TryAgain2
Instead of seeing:

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

I want:

this 1 200

Posted: Sat Jun 16, 2007 11:00 am
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.

Posted: Sat Jun 16, 2007 11:24 am
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.

Posted: Sat Jun 16, 2007 11:59 am
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?

Posted: Sat Jun 16, 2007 3:42 pm
by feyd
Since the textarea is readonly, why not simply not use it?

Posted: Sat Jun 16, 2007 3:53 pm
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"

Posted: Fri Jun 22, 2007 7:13 am
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.

Posted: Fri Jun 22, 2007 7:22 am
by Styx
Then the css is really what you're looking for unless you want to be messy and use something like iframe.

Posted: Fri Jun 22, 2007 7:59 am
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.

Posted: Fri Jun 22, 2007 9:42 pm
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.