August 26th, 2001, 01: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, 04: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 04:21 PM.
August 29th, 2001, 11:55 PM
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, 05: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 + '">')