Simple question - is there any way to select a sub-set of the text displayed in a <textarea> control using Javascript?
e.g. have a function like
selectText(startCharNo, endCharNo, textareaName);
It also needs to be IE6 compatible.
Simple question - is there any way to select a sub-set of the text displayed in a <textarea> control using Javascript?
e.g. have a function like
selectText(startCharNo, endCharNo, textareaName);
It also needs to be IE6 compatible.
yes, it is possible
element.focus();
if(element.setSelectionRange)
element.setSelectionRange(startCharNo, endCharNo);
else {
var r = element.createTextRange();
r.collapse(true);
r.moveEnd('character', endCharNo);
r.moveStart('character', startCharNo);
r.select();
}
element is the reference to the textarea