PDA

View Full Version : How would i enable colours within a text box?



DeanoLaad
Oct 21st, 2009, 04:50 PM
Title really say it all..

How would i enable colours within a text box?

:$

oesxyl
Oct 21st, 2009, 04:57 PM
Title really say it all..

How would i enable colours within a text box?

:$
nope, title is confusing. What colour you want to enable, border, background, text?
what do you mean by enable in fact? when the colors are disabled and what that means?

best regards

DeanoLaad
Oct 21st, 2009, 05:00 PM
nope, title is confusing. What colour you want to enable, border, background, text?
what do you mean by enable in fact? when the colors are disabled and what that means?

best regards

i mean, like.. add colours to differnt words, within the textbox (be it bg or fg colours). Lol

oesxyl
Oct 21st, 2009, 05:12 PM
i mean, like.. add colours to differnt words, within the textbox (be it bg or fg colours). Lol
you can change both background color and color but as far as I know you must change color for all your text not only for some words.
I assume, maybe I'm wrong, that you talk about a textarea but that applay to a input element too.


<textarea row="5" cols="80" id="mycolorbox">colored textarea</textarea>


that's one way:


var txtar = document.getElementById('mycolorbox');
txtar.style.cssText = "background-color: #f00; color: #0f0";


as far as you can't use different colors for different words this is usefull only if you want to change colors on the fly.

best regards

mrhoo
Oct 21st, 2009, 07:09 PM
To have different colors, or any distinct style not shared by every one of them, you need separate inline elements

DeanoLaad
Oct 21st, 2009, 07:57 PM
Hey, iv found what i need to do @geekpedia (http://www.geekpedia.com/tutorial198_Creating-a-Rich-Text-Editor-using-JavaScript.html). Thanks for all your help. =)