contentEditable

T

Trevor

I have an DIV with the contentEditable attribute. How can I get the
value of the content within that DIV after the user has edited it for
further processing. I'd like to store the HTML code within the DIV to a
hidden INPUT. Thanks for your help!
 
J

Jonathan N. Little

Trevor said:
I have an DIV with the contentEditable attribute. How can I get the
value of the content within that DIV after the user has edited it for
further processing. I'd like to store the HTML code within the DIV to a
hidden INPUT. Thanks for your help!
1: I know of no such DIV attribute 'contentEditable'.
2: Why would you use a DIV for user input? There are a whole host of
defined form element for that purpose! Try a FORM with a
TEXTAREA...unless your intentions involve subterfuge...
 
T

Toby Inkster

Jonathan said:
1: I know of no such DIV attribute 'contentEditable'.

It's invalid, true, but it works in IE. Mozilla has a similar, though
slightly different extension.
2: Why would you use a DIV for user input? There are a whole host of
defined form element for that purpose! Try a FORM with a
TEXTAREA...unless your intentions involve subterfuge...

TEXTAREA can't contain bold text, text of varying sizes, italics, etc.
contentEditable allows you to create a little WYSIWYG editor within a page.
It's not much good on the public internet, but is fairly handy for
intranets, and for the admin sections of public sites (e.g. within a CMS
tool).

The OP wants to look at document.getElementById('foo').innerHTML I think.
 
J

Jonathan N. Little

Toby Inkster wrote:
TEXTAREA can't contain bold text, text of varying sizes, italics, etc.
contentEditable allows you to create a little WYSIWYG editor within a page.
It's not much good on the public internet, but is fairly handy for
intranets, and for the admin sections of public sites (e.g. within a CMS
tool).

The OP wants to look at document.getElementById('foo').innerHTML I think.
New one on me, but I have not invested much time on the MSIE only
elements and attributes, I write for the web. Problems I see...

1: MSIE only
2: Requires JavaScript
3: Can create really horrific tag soup with cut'n paste operations /but
then again, this is MSIE, MS is use to parsing junk!/ ;-)

If you want to pass formatted data I ould think something like a Java
app would be better with wider support.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top