|
Q278 How can I reverse text in a form field?
irt.org | Knowledge Base | JavaScript | Text | Q278 [ previous next ]
Q278 How can I reverse text in a form field?
<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>
|
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.