in reply to Re: HTML Problem getting entities into a textarea
in thread HTML Problem getting entities into a textarea

Thanks, but if you try it like I suggested, you'll see the dilema - here is the problem:

I want &lt; to show up as-is, since that is what the user typed when the document was created. If I have them double-escape (or really escape the & with &amp;) then when I save the text, and then display it later (on a technote display page that drops the html in a table cell) it will show as &lt; and not as <

The problem is that most tags inside the textarea tag are NOT interpreted, but the following IS:

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

Basically, I think that this is a bug in the textarea tag for html - any other ideas?

TIA again, Jeff

Replies are listed 'Best First'.
Re: Re: Re: HTML Problem getting entities into a textarea
by dws (Chancellor) on Apr 18, 2003 at 21:05 UTC
    I want &lt; to show up as-is, since that is what the user typed when the document was created.

    If the user literaly typed '&' 'l' 't' ';', then to prevent this from being corrupted when you spit the text back out into a textarea, you're going to need to escape the '&'. This isn't an HTML bug, though it's not the most documented aspect of HTML that you'll find.

      Know what? This problem doesn't seem to exist here in perl monks. It's the same basic idea as here. Folks are entering html in textareas. But if I put this in

      <property key="smtpHost" value=""/>

      it is saved as I typed it - with the escapes, and viewed as I want it - escapes interpreted, and is brought back up in the edit textarea with the escapes intact; uninterpreted.

      What am I missing here? I need so save with all &s escaped to &amp;, and then unescape them to & when I display, but dump it when I edit, or vice versa?