Hi I’m sure this is a simple JavaScript function, but I’m still rather new to them..
The following code below displays letters that are inputted into the form field when typed.
The main objective is to get the word “test” to spell out backwards “tset” (Basically any character inserted from the keypad would input itself backwards).
The form outputs “hello” when inputted properly.
Any ideas anyone?
Thanks!
<html>
<head>
<center>
<script type = “text/javascript”>
function replaceChars() {
var temp = document.subform.text.value;
temp = temp.replace(/tset/gi, “hello”);
document.subform.text.value = temp;
}
</script>
</head>
<body>
<form name=”subform”>
<textarea rows=”8″ name=”text” cols=”48″ value=””></textarea>
<br><br>
<input type=button name=action value=”Change” onClick=”replaceChars(document.subform.text.value);”>
<br><br>
<table border=”1″ width=”284″ id=”table1″ height=”58″ bgcolor=”#FFFFFF”>
<tr>
<td align=”center” width=”70″><INPUT TYPE=”button” NAME=”t” VALUE=” t ” OnClick=”subform.text.value += ‘t'”></td>
<td align=”center” width=”70″><INPUT TYPE=”button” NAME=”e” VALUE=” e ” OnClick=”subform.text.value += ‘e'”></td>
<td align=”center” width=”70″><INPUT TYPE=”button” NAME=”s” VALUE=” s ” OnClick=”subform.text.value += ‘s'”></td>
<td align=”center” width=”70″><INPUT TYPE=”button” NAME=”t” VALUE=” t ” OnClick=”subform.text.value += ‘t'”></td>
</tr>
</table>
</form>
</center>
</body>
</html>