Can div with contenteditable=true be passed through form?

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="https://stackoverflow.com/questions/7355583/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.

Leave a Comment