...

View Full Version : Search and replace



bench
01-20-2003, 05:17 PM
Hi,

I am trying to create a search and replace tool for a WYSIWYG

bench
01-20-2003, 05:18 PM
Hi,

I am trying to create a search and replace tool for a wysiwyg editor, but am unable to do it. So far I have the following code:

function searchfor(){
if (document.table.match[0].checked==true){
var method = 2;
}
else{
var method = 0;
}
var range = opener.editor.document.body.createTextRange();
var result = range.findText(document.table.criteria.value, 0, method);
if (result){
var text = range.select();
text.replace(document.table.criteria.value, "Benjamin Chivers");
opener.editor.focus();
}
else{
alert("Your search returned no results.");
}
}

It finds the string fine, but I do not know how to replace.

Any help on this matter would be most appreciated.

Many Thanx,
Ben Chivers

A1ien51
01-20-2003, 08:41 PM
here is a link for you

http://www.devguru.com/Technologies/ecmascript/quickref/string_replace.html

see if that helps



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum