August 26th, 2001, 02:30 PM
var test = "ó";
alert(test); - shows code
document.write(test); - shows character
Does anyone know a way to render character code as a character in alert() function or form elements?
August 26th, 2001, 05:10 PM
Yeah, that kind of stuff can be confusing. The alert box uses escape codes, and the write method uses html character entities. Try alert(unescape(test))
Sorry...I didn't test that enough. I'll keep trying.
Last edited by evildj; August 26th, 2001 at 05:21 PM.
August 30th, 2001, 12:55 AM
Are you sure it's not just that the font/typeface used in form elements is one that doesn't have what you are expecting for that ASCII equivalent? Try setting your typeface in the rest of your page to Arial and see if the character looks the same, then also try Courier and Courier New. I do know that those kinds of symbols vary from typeface to typeface (and the particular one used in the forms may just not have that entity at all).
August 30th, 2001, 06:27 AM
This one's cropped up before and one slightly obscure way around it is to place the special character into a hidden form field and then alert the value of the field. The alert then displays the character rather than the code. Tried using 'unescape()' as above but that didn't work. Try adapting this:
var str = "&#245;";
document.write('<FORM ID="Dave" NAME="Dave">')
document.write('<INPUT TYPE="HIDDEN" ID="Fred" NAME="Fred" VALUE="' + str + '">')