provare questo
document.getElementById('formtextarea').value=document.getElementById('editable_div').innerHTML;
un esempio completo: -
<script type="text/javascript">
function getContent(){
var div_val=document.getElementById("editablediv").innerHTML;
document.getElementById("formtextarea").value =div_val;
if(div_val==''){
//alert("option alert or show error message")
return false;
//empty form will not be submit. You can also alert this message like this.
}
}</script>
`
<div id="editablediv" contenteditable="true">
<a href="page.html">Some</a> Text</div>
<form id="form" action="action.php" onsubmit="return getContent()">
<textarea id="formtextarea" style="display:none"></textarea>
<input type="submit" />
</form>
`
invece di questo si può utilizzare JQuery (se non v'è il limite per utilizzare JQuery per auto-ridimensionamento textarea o qualsiasi editor di testo WYSIWYG)
fonte
2014-04-02 05:17:47
possibile duplicato di [Utilizzo di HTML5, come utilizzare i campi contenteditable in un modulo di invio?] (Http://stackoverflow.com/questions/6247702/using-html5-how-do-i-use-contenteditable-fields -in-a-form-submission) – dbn