Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q278 How can I reverse text in a form field?

You are here: irt.org | FAQ | JavaScript | Text | Q278 [ previous next ]

<SCRIPT LANGUAGE="JavaScript"><!--
function reverse() {
   var value = document.myForm.myText.value;
   for (var text = '',i=value.length-1;i>-1;i=i-1)
       text += value.charAt(i);
   document.myForm.myText.value = text;
}
//--></SCRIPT>

<FORM NAME="myForm">
<INPUT TYPE="TEXT" NAME="myText">
<INPUT TYPE="BUTTON" onClick="reverse()" VALUE="Press Me">
</FORM>

©2018 Martin Webb