...

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



chapimp
01-20-2003, 01:25 PM
Hi
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




<SCRIPT LANGUAGE="JavaScript">
<!-- 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 -->
</script>
</HEAD>

<BODY>






<form name=search>
Find in Page
<input name=string type=text size=15 onChange="n = 0;">
<input type=button value="Search"
onClick="findInPage(this.form.string.value);">
</form>




<form NAME="copy">


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

one two three four

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

try changing it to this

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

chapimp
01-20-2003, 07:20 PM
That works just fine


Thanks,

farewellspacema
07-21-2005, 12:32 AM
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