Convert Letters

[Total: 0    Average: 0/5]

This example shows how to have text replacement occur by user input into 3 different form text boxes.

Body Code:

<form name=exf1>
<input type=text name=t1 value="a"> 
<input type=text name=t2 value="b">
<BR>
<input type=text name=t3 value="a test pattern to read">
<BR>
<HR>
<input type=text name=t4 value="?">
<BR>
<input type=button value="Filter" onclick="doIt()">
</form>
<script>
function doIt() {
  var _return = "";
  var _t3 = document.exf1.t3.value.split("");
  for (var i in _t3) {
    if (_t3[i].match(document.exf1.t1.value)) {
	  _t3[i] = document.exf1.t2.value;
	}
	_return += _t3[i];
  }
  document.exf1.t4.value = _return;
}
</script>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *