Auto-selecting text for user

G

GeekBoy

Howdy...
I have a textarea with a paragraph of data already in it. There will
be a few unique words in that paragraph which are simply placeholders
and need to be replaced with data, just like a template. For example:
"Hello and welcome, #CUSTNAME#."
I need to be able to automatically jump and select (highlight) that
template field, #CUSTNAME# so the user simply has to type the name to
place it. Currently, the user must first find the field (it could be
a huge paragraph) then carefully take his mouse cursor and select
(highlight) the #CUSTNAME# characters, then he can type over it. I
would like to have the user just press a key (or button, or whatever)
and the system will automatcially find the next #CUSTNAME# field and
automatically select (highlight) it for him... now all he has to do it
type, no mouse required. Any ideas? Thanks!
 
G

GeekBoy

I'll answer this myself since I figured it out:

var TR = document.all.myInputBox.createTextRange();
TR.collapse(true);
if (TR.findText("#CUSTNAME#", 9999999) == true) {
TR.select();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top