String
----------an automatic replacement version----------
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script language= "JavaScript" >
var Staus;
var ORange;
var Objtimer;
var objTimer1;
var objTimer2;
var Sbookmark;
<!--
function SelectAll (objall,objsingle) {
alert (objall.checked);
for (Var i=0;i<objsingle.length;i++) {
if (objall.checked) {
For (Objs in Objsingle) {
alert (Objs.value);
Objs.checked=true;
}
}
else{
Objsingle.checked=false;
}
}
}
function Fnsearch () {
Fm1.txtarea1.focus ();
ORange = Fm1.txtarea1.createTextRange ();
Searchtxt (1);
}
function Searchtxt (n) {
VAR v1;
VAR v2;
var txtr;
var Blns;
Window.clearinterval (ObjTimer1);
Window.clearinterval (OBJTIMER2);
V1 = Fm1.txtarea1.value;
v2 = Fm1.txtarea2.value;
V3 = Fm1.txtarea3.value;
if (n = = 1) {
if (ORange!= null) {
Orange.findtext (v2);
if (Orange.findtext (v2) = = True) {
Sbookmark = Orange.getbookmark ();
Orange.select ();
Orange.scrollintoview ();
ObjTimer2 = Window.setinterval ("Searchtxt (2)", 1000);
}
else{
Objtimer = Window.setinterval ("Searchtxt (3)", 1000);
}
}
Staus = 2;
}
else if (n==2) {
Orange.text = v3;
Staus = 1;
ObjTimer1 = Window.setinterval ("searchtxt (1)", 1000);
}
else if (n==3) {
Staus = 3;
Window.clearinterval (Objtimer);
Window.clearinterval (ObjTimer1);
Window.clearinterval (OBJTIMER2);
}
}
-->
</SCRIPT>
</HEAD>
<BODY>
<form method=post name= "FM1" >
<textarea name= "txtarea1" rows= "cols=" >
This is the original text and that is the ' is ' repalced.
This is the original text and that is the ' is ' repalced.
This is the original text and that is the ' is ' repalced.
This is the original text and that is the ' is ' repalced.
This is the original text and that is the ' is ' repalced.
This is the original text and that is the ' is ' repalced.
</TEXTAREA>
<textarea name= "txtarea2" rows= "cols=" > would be </TEXTAREA>
<textarea name= "Txtarea3" rows= "cols=" > has been </TEXTAREA>
<input type= "button" value= "Search" >
</FORM>
</BODY>
</HTML>
--------------------------------Manually Improved version----------------------------------------
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script language= "JavaScript" >
var ORange; Save the current TextRange
var intcount = 0; This POS is of current TextRange in total count
var inttotalcount = 0; Total Count
<!--
//==============================================
Function:fnsearch ()
Comment:search the text
Param:none
Return:none
Author:fantiny
date:10/21/2005
//==============================================
function Fnsearch () {
var strbereplaced;
var strreplace;
strbereplaced = Fm1.txtarea2.value;
Strreplace = Fm1.txtarea3.value;
Fnnext ();
Fm1.txtarea1.focus ();
ORange = Fm1.txtarea1.createTextRange (); Create a textRange for the Textarea
Find the text by FindText method
For (I=1 orange.findtext (strbereplaced)!=false; i++) {
if (I==intcount) {
Orange.select (); Select the finded text
Orange.scrollintoview (); Scroll the page and set the text into View
Break
}
Orange.collapse (FALSE); //
}
}
//==============================================
Function:fnsearch ()
Comment:set the flag to the next TextRange
Param:none
Return:none
Author:fantiny
date:10/21/2005
//==============================================
function Fnnext () {
if (intcount > 0 && intcount < inttotalcount) {
intcount = intcount + 1;
}
else{
intcount = 1;
}
}
//==============================================
Function:init ()
Comment:initialize at page onload to get the count
Param:none
Return:none
Author:fantiny
date:10/21/2005
//==============================================
function init () {
var ORange;
var strberepalced;
ORange = Fm1.txtarea1.createTextRange (); Create a textRange for the Textarea
strbereplaced = Fm1.txtarea2.value;
For (i=0 orange.findtext (strbereplaced)!=false; i++) {
Orange.collapse (FALSE); Moves the "insertion" to the "end of" the text range.
}
Inttotalcount = i;
}
//==============================================
Function:fnreplace ()
Comment:replace the text of the selected TextRange
Param:none
Return:none www.knowsky.com
Author:fantiny
date:10/21/2005
//==============================================
function Fnreplace () {
var strreplace;
Strreplace = Fm1.txtarea3.value;
If the TextRange is exist, replace the text
if (orange!= null && typeof (ORange) = = "Object" && inttotalcount > 0) {
Orange.text = Strreplace;
intcount = intCount-1;
Inttotalcount = intTotalCount-1;
ORange = null;
}
}
-->
</SCRIPT>
</HEAD>
<body >
<form method=post name= "FM1" >
<textarea name= "txtarea1" rows= "cols=" >
This is the original text and that is the ' is ' repalced.
This is the original text and that is the ' is ' repalced.
This is the original text and that is the ' is ' repalced.
This is the original text and that is the ' is ' repalced.
This is the original text and that is the ' is ' repalced.
This is the original text and that is the ' is ' repalced.
</TEXTAREA>
<textarea name= "txtarea2" rows= "cols=" > would be </TEXTAREA>
<textarea name= "Txtarea3" rows= "cols=" > has been </TEXTAREA>
<input type= "button" value= "Search" >
<input type= "button" value= "Replace" >
</FORM>
</BODY>
</HTML>