views:

2032

answers:

2

Guys,

I want to create some text based on user input, and when user enter some text, the first word will automatically set backgroundcolor, but the other words still remain same (no background color), can I do this ?

Thanks

A: 

You could do it with an iFrame if you turn designMode on, add an event listener for keypress then wrap the first word in the iFrames body with <span style='background-color: red'></span>. You would then have to have a hidden form field that mirrored the data that is typed into the iFrame (removing the span tag).

If you want to go this way let me know if you need any more help.

Kane Wallmann
+1  A: 

WYSIWYG editor will be the best choice for previewing text and editing at the same time.

Some popular ones are

  1. TinyMCE
  2. STEditor
  3. FCKeditor
rahul