You are here: irt.org | FAQ | JavaScript | Text | Q279 [ previous next ]
<SCRIPT LANGUAGE="JavaScript"><!-- var coding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMabcdefghijklmnopqrstuvwxyzabcdefghijklm'; function rot13() { var value = document.myForm.myText.value; for (var text = '',i=0;i<value.length;i++) { character = value.charAt(i); position = coding.indexOf(character); if (position > -1) character = coding.charAt(position + 13); text += character; } document.myForm.myText.value = text; } //--></SCRIPT> <FORM NAME="myForm"> <TEXTAREA COLS="80" ROWS="40" NAME="myText"></TEXTAREA> <INPUT TYPE="BUTTON" onClick="rot13()" VALUE="Press Me"> </FORM>