Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outputting htmlspecialchars ...

Status
Not open for further replies.

dbeezzz

Technical User
Nov 30, 2005
54
KR
I'm outputting a page of html as a value for in an <input tag
Code:
<div><input type="hidden" id="editor1" name="editor1" value=
"&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt; ... "

I need to serve up the page as htmlentities in order to fit it into the value part of my <input>.

Unfortunately though, serving up the <img src="" part doesn't work as <img src=&quot;&quot;

Is there any way around this from a html perspective ?
 
How doesn't it work? Do you not see the "img src" text in the input?

That aside, you should serve "<img" as "&lt;img" if it is part of an attribute value - which it is, in this case, if I've understood correctly.

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
thanks dan,

I should have been clearer ... my image tags are output like this
Code:
 <img src=&quot;Templates/Classic/images/line.jpg&quot; alt=&quot;&quot; border=&quot;0&quot; height=&quot;7&quot;
 width=&quot;202&quot;>
      <br>
... the width/height atrributes are fine, it's just that the image itself isn't rendered on the page.
 
You could try using single quotes instead of &quot;s:
Code:
<input type="hidden" id="editor1" name="editor1" value=" ... &lt;img src='Templates/Classic/images/line.jpg' alt='' border='0' height='7' width='202'&gt; ... ">
What are you actually trying to do? Squeezing a whole page of HTML into a hidden <input> seems quite strange.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Ya thanks guys,

It was a bit strange and to be honest I still am not fully sure of exactly what's going on. Basically I'm combining a php templating system with the FCKEditor.

So my html is going through a couple of loops and then is being output to the editor page. I've got it sorted now though, thanks anyway. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top