富文本编辑器(使用YUI简单文本编辑器)未将数据发送到下一页
Rich Text Editor (YUI Simple Text Editor used) not sending data to next page
我使用YUI中的一个简单文本编辑器,但当我单击提交时,文本区域/编辑器中的代码不会发送到下一页。我希望能够在后续页面上接收它,然后将其存储在数据库(MySql)中。我已经浪费了很多时间。请帮忙。HTML文件:
<html>
<head>
<script type="text/javascript" src="http://yui.yahooapis.com/combo?2.9.0/build/yahoo-dom-event/yahoo-dom-event.js&2.9.0/build/container/container_core-min.js&2.9.0/build/element/element-min.js&2.9.0/build/editor/simpleeditor-min.js"></script>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.9.0/build/editor/assets/skins/sam/simpleeditor.css" />
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.2r1/build/assets/skins/sam/skin.css">
<!-- Utility Dependencies -->
<script src="http://yui.yahooapis.com/2.8.2r1/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script src="http://yui.yahooapis.com/2.8.2r1/build/element/element-min.js"></script>
<!-- Needed for Menus, Buttons and Overlays used in the Toolbar -->
<script src="http://yui.yahooapis.com/2.8.2r1/build/container/container_core-min.js"></script>
<script src="http://yui.yahooapis.com/2.8.2r1/build/menu/menu-min.js"></script>
<script src="http://yui.yahooapis.com/2.8.2r1/build/button/button-min.js"></script>
<!-- Source file for Rich Text Editor-->
<script src="http://yui.yahooapis.com/2.8.2r1/build/editor/editor-min.js"></script>
<script>
YAHOO.util.Event.on('submit', 'click', function() {
myEditor.saveHTML();
var html = myEditor.get('element').value;
});
(function() {
var Dom = YAHOO.util.Dom,
Event = YAHOO.util.Event;
var myConfig = {
height: '200px',
width: '900px',
dompath: true,
};
myEditor = new YAHOO.widget.SimpleEditor('msgpost', myConfig);
myEditor.render();
})();
</script>
</head>
<body class="yui-skin-sam">
<form action="submit.php" method="post">
<textarea name="msgpost" id="msgpost" cols="50" rows="10"></textarea>
<input type="submit" value="Submit" onsubmit="return myDoSubmit()"/>
</form>
</body>
</html>
您使用的saveHTML()
方法似乎没有将值保存到textarea
元素。因为浏览器不关心YUI编辑器,只提交textarea
中已经存在的内容(为null),所以它将输入提交为null。。
您应该将textarea
的值设置为编辑器值,以便浏览器提交该值而不是null。。使用这条细线可以实现:
document.getElementsById("msgpost").value = html;
看看这个工作Js我为你做的报价。
但是,您也有HTML
语法错误。onSubmit
属性应该在form
元素上,而不是提交按钮上。
当您可以在表单提交时简单地调用函数时,收听事件是不实际的。。(参见JsFiddle)
我在这篇文章中看到了一个例子。
基本上,将其添加到myConfig:handleSubmit: true
myConfig将如下所示:
var myConfig = {
height: '200px',
width: '900px',
dompath: true,
handleSubmit: true
};
相关文章:
- 用于用户内容的简单代码编辑器/文本格式化程序(在Rails中)
- 在不更改HTML源代码的情况下,在管理员TinyMCE编辑器中突出显示文本
- Sitecore富文本编辑器-添加按钮
- Codemirror:将特定的基于模式的文本隐藏到编辑器中
- 使用PageMod将所有文本框转换为所见即所得HTML编辑器
- 正在寻找具有多种功能的文本编辑器
- 简单的Javascript文本编辑器或一组函数
- EXTJS 4.2 为行实现多个编辑器 xtype 编辑网格
- 在所见即所得编辑器中编辑,,等
- 如何在javascript中获取编辑器文本框的值
- 仅当具有 1 个工具栏的多个编辑器的编辑器处于焦点中时,才显示 TextAngular 工具栏
- CK编辑器文本对齐按钮
- CK编辑器文本对齐工具栏按钮
- 如何更改富文本编辑器文本区域中的插入符号偏移量
- 自定义WordPress管理菜单:如何使编辑器可编辑
- CodeMirror:如何在光标位置之前或之后读取编辑器文本
- 在“更改”时检索编辑器文本更改的某种方法是解雇
- 使用asp.net在数据库中保存richtext编辑器文本时删除内联样式
- Ace编辑器-在编辑器中添加超链接
- Ace JS编辑器-在编辑器中启用/禁用撤销和重做按钮