Código HTML:
<html> <head> <SCRIPT LANGUAGE="JavaScript"> function replaceChars(entry) { out = "a"; add = "z"; temp = "" + entry; while (temp.indexOf(out)>-1) { pos= temp.indexOf(out); temp = "" + (temp.substring(0, pos) + add + temp.substring((pos + out.length), temp.length)); } document.form1.text.value = temp; } </script> </head> <body> <form name="form1"> <input type=text name=text size=40 value="abcdabcd"><br> <input type=button name=action value="Reemplazar" onClick="replaceChars(document.form1.text.value);"> </form> </body> </html>