highlighting or changing background of some text in input box

J

James Black

Hello,
I am trying to add an autocomplete functionality for tags, so I want
to just have the following capability:
If I type
ger

then the word my application matches that to is
german

So, I want 'ger' to look normal, and 'man' to be highlighted.

In an input box I can't use html tags, but I believe there is a
javascript function that will allow me to highlight just the part I
want highlighted.

How would I do this?

Thanx.
 
D

David Mark

Hello,
I am trying to add an autocomplete functionality for tags, so I want
to just have the following capability:
If I type
ger

then the word my application matches that to is
german

So, I want 'ger' to look normal, and 'man' to be highlighted.

You mean you want "man" to be selected.
In an input box I can't use html tags, but I believe there is a
javascript function that will allow me to highlight just the part I
want highlighted.

Look into createTextRange for IE and setSelectionRange for others.
The former creates a range object, which can then be manipulated to do
what you want. The latter can do it with one call. Make sure you
detect these methods before calling.
 
J

James Black

You mean you want "man" to be selected.

I was hoping to be able to arbitrarily change the background for the
part I want selected, but that appears to not be possible.
Look into createTextRange for IE and setSelectionRange for others.
The former creates a range object, which can then be manipulated to do
what you want. The latter can do it with one call. Make sure you
detect these methods before calling.

Thank you very much.
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top