Find Location of Text

[Total: 0    Average: 0/5]

This will search for the location of a pattern in a text area.

Body Code:

<form name=f1>
<textarea name=t1>this is some text inside the textarea</textarea>
<input type=button value="click to find position of 'text'" onclick="doIt()">
<BR>Position:<input name=t2 type=text readonly value="">
</form>
<script>
function doIt()
{
  var FIND="text";
  var x=document.f1.t1.value;
  var y=x.indexOf(FIND)
  document.f1.t2.value=y;
}
</script>

Times Viewed: 0

Leave a Reply

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