简体   繁体   English

通过所见即所得的形式发布

[英]passing form post with WYSIWYG

I am trying to pass form values through post form but nothing shows. 我正在尝试通过邮寄表格传递表格值,但没有显示。

using this HTML5 Text Editor http://suyati.github.io/line-control/ I'm using this method for form and php code 使用此HTML5文本编辑器http://suyati.github.io/line-control/我正在使用此方法生成表单和php代码

<?php
if(isset($_POST['submit'])){
    echo $_POST['txtEditor'];
}
?>

html form i am using 我正在使用的HTML表单

                 <form method="post">
                   <textarea name="txtEditor" id="txtEditor" ></textarea>
                   <input name="submit" type="submit" value="Submit">
                 </form>

and the java script is Java脚本是

<script src="WYSIWYG-Text-Editor/editor.js"></script>
<script>
    $(document).ready(function() {
        $("#txtEditor").Editor();
    });
</script>

Have checked the doc and apparently you need to set the value by yourself, here is a solution: 检查了文档,显然您需要自己设置值,这是一个解决方案:

Add some code to your initialization code: 在初始化代码中添加一些代码:

<script>
    $(document).ready(function() {
        $("#txtEditor").Editor();
        $('form').submit(function () {
            $('#txtEditor').val($('#txtEditor').Editor('getText'));
        });
        $('#txtEditor').Editor('setText', $('#txtEditor').val());
    });
</script>

On form submit we actually set the textarea value with what the user input in the WYSISWYG. 在表单提交中,我们实际上使用用户在WYSISWYG中输入的内容来设置textarea值。

In the next line of code we set the value of the WYSISWYG with what value comes in the textarea (as you requested in your comment). 在下一行代码中,我们将WYSISWYG的值设置为textarea中的值(如您在注释中所要求的)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM