views:

37

answers:

2

I need to add a font color changing tool section in my form's text area same as we have in our mail boxes.I tried to find on net but didnt get anything useful.Please tell me how can i implement that font color changing tool on my page using javascript????

A: 

Simplest way would be to use something like: http://developer.yahoo.com/yui/examples/editor/simple_adv_editor.html

unomi
i cant use nay widget or so ...i need an individual script for it.
developer
Then the only option is doing some work ;) Make a color selector, you can start with simply a dropdown of colors to choose from. Find the selected range http://www.quirksmode.org/dom/range_intro.htmland wrap it in a span with that font-color. And then you have to figure out how you are going to position the div overlay/underlay that will contain the marked up text ;)
unomi
A: 

Color pickers are readily available on the net. Just google for "colorpicker yourFavJSLib". Some results will be:

Basically, all you have to do is let the user pick a color and then change the CSS color property with JavaScript for that eMail. You will also want to save the color value for this eMail on the server so it gets reapplied when the page is reloaded.

As an alternative, let users tag their eMails and let them assign colors to the tags instead of the eMail directly. Then store the tags instead of individual colors. Apply the tags as CSS classes.

EDIT: if you want the users to allow for RichText Editing/Composing, either use a readymade component. If you cannot use one, use a color picker and wrap the selected text portion into 'span' tags - but there's really no reason to reinvent the wheel here.

Gordon