views:

241

answers:

4

hi

have to build a system that when a user write in a box a word that starts with # this is wrapped inside an html element. Inside input-text and textarea html don't work. I had thought with a div, is possible?

+2  A: 

Try the following:

<div contenteditable="true">Hello, edit me!</div>

Not tested in Opera, works in Firefox 3, Google Chrome, Safari and Internet Explorer 6, 7 and 8.

Andy E
on what planet does this work?
Chris Lively
works only on firefox...
Angelbit
@Angelbit: try it using "true" as the value, that will work in IE.
Andy E
@Chris Lively - Melmac :)
Joel Etherton
@Chris: It would work fine in Firefox 3, but after your comment I realized IE wouldn't accept XHTML-style attribute/value pairs.
Andy E
@Andy: with the edit it works with IE now. cool
Chris Lively
huh... i had no idea about this. :)
Code Monkey
Also works in IE 5.5, in case anyone cares.
Tim Down
@Tim: I don't think anyone does ;-)
Andy E
A: 

Yes, this is possible.

:)

Seriously, you'll need to parse user input and when your parser engine see a "#" symbol, it just wait for the next [space] (for example as a element id delimiter), create a new DOM Element with this id and after that it must update innerHTML of this element by everytime user entered a symbol.

Sergey Kuznetsov
yes, have altredy the parser, now need a system like @ facebook that highlighting the #word like FB
Angelbit
+3  A: 

Not sure exactly what you are looking for, but you can make divs editable like this:

<div contentEditable="true"></div>

einarq
+1 I didn't know this was even possible. Nice.
Chris Lively
A: 

Not sure why a input or textarea won't work; you might consider handling the events fired when a user enters data into a textarea or a input to accomplish your goal. Or you might look into a wysiwyg editor.

Upper Stage