I have a function that inserts some text into a textarea. The text is a placeholder for some data merging, and looks like %%FieldName%%. I have run into an issue where when i insert the text %%FaxNumber%%, it inserts it as '%úx Number%%'.
I've done a few tests which rules out the function, but seems the issue is with the parameter to the function. If i pass '%Fa' it converts it to ú. Is there anyway i can stop this from happening??
To test this, in a blank html document add the line:
You will be prompted with 'ú'. There is no doctype, im using quirks mode (to take advantage of 100% height).
Thanks in advance for any help.
You should not work in quirks mode, to take advantage of the strict standard coding. It is well known that browsers act unforeseeable in quirks mode, this is the reason for a DTD is required.
Originally Posted by jimloko
Have you set also the meta charset?
Just remember that %FA translates to the decimal character 250 when it represents it.
You could try escaping the string first so it appears normal:
Meta charset is UTF-8. This is an older app i've taken over and will be putting into a new template, with a DTD!
The only problem with escaping the string is it ends up being URL encoded, so the example field name ends up as '%25%FaxNumber%25%25', which doesn't quite do it.
So i really dont understand why its encoding, even with a DTD and encoding specified!
Ok, here are some tests I have tried:
<b>Plain HTML</b><br />
<input type="text" value="%%FieldName%% - %%FaxNumber%%" onclick="alert(this.value);" />
<div onclick="alert(this.innerHTML);">%%FieldName%% - %%FaxNumber%%</div>
<textarea onclick="alert(this.value);">%%FieldName%% - %%FaxNumber%%</textarea>
<input id="inputs" type="text" onclick="alert(this.value);" />
<div id="divs" onclick="alert(this.innerHTML);"></div>
<textarea id="textareas" onclick="alert(this.value);"></textarea>
<a href="#" onclick="alert('%FA');">Click Me (onclick)</a><br />
document.getElementById("inputs").value = "%%FieldName%% - %%FaxNumber%%";
document.getElementById("divs").innerHTML = "%%FieldName%% - %%FaxNumber%%";
document.getElementById("textareas").value = "%%FieldName%% - %%FaxNumber%%";
alert("%%FieldName%% - %%FaxNumber%%");
Yep, that all looks right.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread