可以用contenteditable = true div来通过表单吗? [英] Can div with contenteditable=true be passed through form?

查看:124
本文介绍了可以用contenteditable = true div来通过表单吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以< div contenteditable =true>< a href =page.html>某些< / a> Text< / div> 用来代替texarea,然后以某种方式传递低谷形式? 理想情况下没有JS

解决方案

元件。只有javascript可以让它工作。



编辑:回应你的评论...这应该可以。

 < script type =text / javascript> 
function getContent(){
document.getElementById(my-textarea)。value = document.getElementById(my-content)。innerHTML;
}
< / script>


< div id =my-contentcontenteditable =true>< a href =page.html>一些< / a>文字< / DIV>

< form id =formaction =some-page.phponsubmit =return getContent()>
< textarea id =my-textareastyle =display:none>< / textarea>
< input type =submit/>
< / form>

我已经测试并验证过这个功能可以在FF和IE9中使用。


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

解决方案

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 type="text/javascript">
    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 id="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.

这篇关于可以用contenteditable = true div来通过表单吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆