View Full Version : Search in Textarea only....Script..needed

01-20-2003, 12:25 PM
as you can see this is a search in page script
but , i want to know if it can be re-edited so
that when I look for a word or letter the script would only search
in the Textarea only not out side of it

<!-- Begin
var NS4 = (document.layers);var IE4 = (document.all);var win = this;var n = 0;
function findInPage(str) {var txt, i, found;if (str == "")return false;if (NS4) {
if (!win.find(str))while(win.find(str, false, true))n++;elsen++;
if (n == 0) alert(str + " was not found on this page.");}if (IE4) {
txt = win.document.body.createTextRange();for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {txt.moveStart("character", 1);txt.moveEnd("textedit");}if (found) {
txt.moveStart("character", -1);txt.findText(str);txt.select();txt.scrollIntoView();n++;
}else {if (n > 0) {n = 0;findInPage(str);}else
alert(str + " was not found on this page.");}}return false;}
// End -->


<form name=search>
Find in Page
<input name=string type=text size=15 onChange="n = 0;">
<input type=button value="Search"

<form NAME="copy">

<textarea NAME="txt" ROWS=5 COLS=25 WRAP=VIRTUAL>
one two three four</textarea>

one two three four

01-20-2003, 04:47 PM
txt = win.document.body.createTextRange();

try changing it to this

txt = win.document.FormName.ElementName.createTextRange();

01-20-2003, 06:20 PM
That works just fine


07-20-2005, 11:32 PM
this script is great. can anyone point me in the right direction for how to modify this to work in firefox?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum