Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can div with contenteditable=true be passed through form?

Tags:

html

Can <div contenteditable="true"><a href="page.html">Some</a> Text</div> be used instead of texarea and then passed trough form somehow?

Ideally without JS

like image 241
JDDll Avatar asked Sep 08 '11 23:09

JDDll


People also ask

What is the role of Contenteditable true attribute?

The contenteditable attribute specifies whether the content of an element is editable or not. Note: When the contenteditable attribute is not set on an element, the element will inherit it from its parent.

What is Contenteditable Div?

Definition and Usage The contenteditable attribute specifies whether the content of an element is editable or not.

What is Contenteditable true?

The contenteditable is used to specify whether the element's content is editable by the user or not. Syntax: <element contenteditable="true|false"> This attribute has two values. true: If the value of the contenteditable attribute is set to true then the element is editable.

What is the HTML attribute Contenteditable used for?

The contenteditable global attribute is an enumerated attribute indicating if the element should be editable by the user. If so, the browser modifies its widget to allow editing.


1 Answers

Using HTML5, how do I use contenteditable fields in a form submission?

Content Editable does not work as a form element. Only javascript can allow it to work.

EDIT: In response to your comment... This should work.

<script>     function getContent(){         document.getElementById("my-textarea").value = document.getElementById("my-content").innerHTML;     } </script>   <div id="my-content" contenteditable="true"><a href="page.html">Some</a> Text</div>  <form action="some-page.php" onsubmit="return getContent()">     <textarea id="my-textarea" style="display:none"></textarea>     <input type="submit" /> </form> 

I have tested and verified that this does work in FF and IE9.

like image 143
smdrager Avatar answered Sep 20 '22 23:09

smdrager