Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

color change onkeydown or blur

Status
Not open for further replies.

codeone

Programmer
Mar 25, 2003
343
US
hey,
Im still working on this one, I am trying to make the text in the textarea change color according to a pre-assigned word...

I still assume that arrays are the way...

and I suppose the css would be the answer to changing the color..

but, I have no idea how to setup the array to search for the keyinput and then change it to the specified color..

all help is appreciated,

code one
 

You'd need to parse your textarea value with each keystroke.

You should be able to assign an onKeyPress event (or maybe onKeyDown) to the textarea, which could call a javascript function, and scan the text for specific values every time a key is pressed.

I'm not sure if you can change the colour of specific text only within a textarea, however... As far as I know, you can only change the colour of all of the text.

Hope this helps!

Dan
 
I think your right, unless there is a way to do it in the array...

something like:

Code:
var clr = new Array(3)
clr[0]="Javascript" if (document.styleSheets) style.this.color='red';
clr[1]="Html" if (document.styleSheets) style.this.color='red';
clr[2]="Table" if (document.styleSheets) style.this.color='red';

you know something like that..can some one please show me how to setup the array to allow for css code to change the specified words color..

thanks

co
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top