By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,934 Members | 1,441 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,934 IT Pros & Developers. It's quick & easy.

finding next occurance of string after first is found in textarea / textbox

P: n/a
Hello.

I've got this js function I call from an html input button. It finds
the occurance of a string in a textbox, selects it and scrolls into
view.

JS newbie question, considering it's a function called from a buttons'
onlclick=, how can I change this code to search the textbox from the
cursor on to the end?

function searchtxt(n){
var what=n;
var d=document;
var el=d.getElementById("editwindow");
var r=el.createTextRange();
var found = r.findText(what);
r.select();
r.scrollIntoView();
}
Many thanks for any help or info -
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
rh
ja***@cyberpine.com wrote in message news:<ef**************************@posting.google. com>...
Hello.

I've got this js function I call from an html input button. It finds
the occurance of a string in a textbox, selects it and scrolls into
view.

JS newbie question, considering it's a function called from a buttons'
onlclick=, how can I change this code to search the textbox from the
cursor on to the end?

function searchtxt(n){
var what=n;
var d=document;
var el=d.getElementById("editwindow");
var r=el.createTextRange();
var found = r.findText(what);
r.select();
r.scrollIntoView();
}


In that case you want to create the range as:

var r = d.selection.createRange();

And depending on the intended use of the search function, you may wish
to follow that with:

r.collapse(false)

to move the cursor beyond any selected text (which may have resulted
from a previous findText operation).

..\rh
Many thanks for any help or info -

Jul 20 '05 #2

P: n/a
Ivo
ja***@cyberpine.com wrote
I've got this js function I call from an html input button. It finds
the occurance of a string in a textbox, selects it and scrolls into
view.

JS newbie question, considering it's a function called from a buttons'
onlclick=, how can I change this code to search the textbox from the
cursor on to the end?


onmousedown works on my Windows, but not my neighbour's Mac. But Mac
has a problem with document.selection already..
<input type="button" onmousedown="thefunction()">
ALternatively, try the calculation onmouseover and using the reslt of
that onclick.
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.