Connecting Tech Pros Worldwide Help | Site Map

displaying special characters in a <div>

Jens Kristensen
Guest
 
Posts: n/a
#1: Jul 20 '05
I have a problem displaying a divbox containing a html-textarea -
everything works fine with "normal" characters. However, when the
textarea contains special chars like <P> or ' , the box fails to show:

function show(divbox)
{
divbox.style.display='';
}

<div id="divbox" style="display:none" >
<form action="action.php" method="post>
<textarea name ="txt">Text</textarea>
</form>
</div>

If the Text in the textarea is for instance
HERE IS A "QUOTE"

it works fine, while
HERE IS A 'QUOTE'
produces an error

<br>-tags works fine, but
<p>-tags doesn't

Hmmm - hope someone can help...

:o)
Jens

VK
Guest
 
Posts: n/a
#2: Jul 20 '05

re: displaying special characters in a <div>


use &lt; and &gt; instead
&lt;P&gt; not <P>
Jens Kristensen <groucho@stofanet.dk> wrote in message
news:3F703E15.169E58E1@stofanet.dk...[color=blue]
> I have a problem displaying a divbox containing a html-textarea -
> everything works fine with "normal" characters. However, when the
> textarea contains special chars like <P> or ' , the box fails to show:
>
> function show(divbox)
> {
> divbox.style.display='';
> }
>
> <div id="divbox" style="display:none" >
> <form action="action.php" method="post>
> <textarea name ="txt">Text</textarea>
> </form>
> </div>
>
> If the Text in the textarea is for instance
> HERE IS A "QUOTE"
>
> it works fine, while
> HERE IS A 'QUOTE'
> produces an error
>
> <br>-tags works fine, but
> <p>-tags doesn't
>
> Hmmm - hope someone can help...
>
> :o)
> Jens
>[/color]


Lasse Reichstein Nielsen
Guest
 
Posts: n/a
#3: Jul 20 '05

re: displaying special characters in a <div>


Jens Kristensen <groucho@stofanet.dk> writes:
[color=blue]
> I have a problem displaying a divbox containing a html-textarea -
> everything works fine with "normal" characters. However, when the
> textarea contains special chars like <P> or ' , the box fails to show:[/color]

What, exactly, is supposed to happen, and what happens (and in which
browser)?
[color=blue]
> function show(divbox)
> {
> divbox.style.display='';
> }[/color]

How is this function called?
[color=blue]
> <div id="divbox" style="display:none" >
> <form action="action.php" method="post>[/color]

You are missing a " after "post". That can very well give problems.
[color=blue]
> <textarea name ="txt">Text</textarea>
> </form>
> </div>
>
> If the Text in the textarea is for instance
> HERE IS A "QUOTE"
>
> it works fine, while
> HERE IS A 'QUOTE'
> produces an error[/color]

Neither " nor ' are special characters in HTML, except inside tags,
so it shouldn't matter which you use.
I guess that the missing " could give that effect.
[color=blue]
> <br>-tags works fine, but
> <p>-tags doesn't[/color]

Where? Inside the textarea element?
The content of the textarea is not HTML, and you should not write tags
there. If you need to write the text "<br>", do it as &lt;br&gt;. If you
need a newline, make one in the source.

/L
--
Lasse Reichstein Nielsen - lrn@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jens Kristensen
Guest
 
Posts: n/a
#4: Jul 20 '05

re: displaying special characters in a <div>


I have finally spotted the problem, which was - not the html tags, but the
line-break ,\n, which in another line caused the script to stall.
Removing the \n-code solved the problem.

Thank you for helping me with the problem

:o)
Jens

Closed Thread


Similar JavaScript / Ajax / DHTML bytes