Click to See Complete Forum and Search --> : why?


Charlos
01-22-2004, 12:34 PM
If i do this

<input type="text" id="tt" value="<%=server.HTMLEncode("&")%>">

i see & but if i do this


document.getElementById("tt").value="<%=server.HTMLEncode("&")%>";


I obtain &amp;amp; and not &

CardboardHammer
01-22-2004, 03:20 PM
Because in the first one you're writing HTML to a place HTML belongs and in the second one, you're assigning HTML to where a plaintext string is expected on the clientside.

Look at your page source. You assigned "&amp;amp;" with the script and that's exactly what you got. I imagine there's some function in javascript to decode, so you'd need to use it when doing the assignment.