You are here: irt.org | FAQ | JavaScript | Text | Q362 [ previous next ]
Try the following which is set for aacute, eacute, iacute, oacute, uacute:
<FORM NAME="test"> <INPUT TYPE="TEXT" NAME="output" SIZE="60"> <INPUT TYPE="BUTTON" VALUE="Convert" onclick="doit()"> </FORM> <SCRIPT LANGUAGE="JavaScript"><!-- function replace(string,text,by) { // Replaces text with by in string var strLength = string.length, txtLength = text.length; if ((strLength == 0) || (txtLength == 0)) return string; var i = string.indexOf(text); if ((!i) && (text != string.substring(0,txtLength))) return string; if (i == -1) return string; var newstr = string.substring(0,i) + by; if (i+txtLength < strLength) newstr += replace(string.substring(i+txtLength,strLength),text,by); return newstr; } function doit() { text = document.test.output.value; text = replace(text,'a/',unescape('%E1')); text = replace(text,'e/',unescape('%E9')); text = replace(text,'i/',unescape('%ED')); text = replace(text,'o/',unescape('%F3')); text = replace(text,'u/',unescape('%FA')); document.test.output.value = text; } //--></SCRIPT>