As you can tell from the title this is actually more of an HTML question. I have a perl cgi script for a knowledge base that allows folks to add technotes as html. Everything works fine, except html escapes in textareas. For example:

If a user is adding a technote that refers to xml edits, and they want to escape the < by using "&lt;" then the file gets posted and saved fine by my script. But when the user comes back to edit the document again, and I spit it out between the textarea tags - it stays that way in the html source, but in the textarea the &lt; gets traslated to < and when it is saved, the xml tags that were in the technote to be modifed as text are now interpreted as html/xml tags and not text to be displayed in the textarea.

Funny enough the <pre> <code> tags dont help - they aren't interprested as tags, but rather displayed.

Does anyone know a way around this? or are textareas just crappy for editing html? Maybe some type of javascript?

Here is some example code - I've escaped the < and > so that it will show ok in here:

<textarea>&lt;property key="smtpHost"        value=""/&gt;</textarea>

Just drop this in an html doc, and you will see that the escapes will show as <> and not &lt; and &gt; in the textarea

I'll probobly get bashed since the answer has little to do with perl, but I figured if anyone might know, it'd be the Perl Monks

TIA, Jeff


In reply to HTML Problem getting entities into a textarea by muad33b

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.