如何显示文本编辑器值

时间:2016-09-17 12:47:18

标签: php html

<form id="staff_add" class="form-horizontal" action="trmser.php" method="post" autocomplete="off">   
 <textarea class="form-control input-sm" id="txtEditor" name="details" placeholder="Details">
        <?php //echo $value['details'];?>
        </textarea>
<button type="submit">Submit</button>
</form>
    <script>
            $(document).ready(function() {
                $("#txtEditor").Editor();
            });
        </script>

trmser.php

<?php echo $_POST['details'];?>

表单提交文本编辑器值不显示
请帮帮我。

1 个答案:

答案 0 :(得分:2)

我假设你正在使用Linecontrol? 您需要添加document.submit部分以从编辑器中读取数据并将其粘贴到textarea中。见下文:

<head>
    <!-- your other scripts like jquery & bootstrap -->
    <script src="editor.js"></script>
    <script>
        $(document).ready(function() {
            $("#txtEditor").Editor();
        });

        $(document).submit(function(){
            $("#txtEditor").val($("#txtEditor").Editor("getText"));
        });
    </script>
</head>
<body>    
   <form action="myscript.php" method="post">
        <textarea class="form-control input-sm" id="txtEditor" name="details" placeholder="Details">
        </textarea>
        <button type="reset">Reset</button>
        <button type="submit">Submit</button>
    </form>
    <?php echo $value['details'];?>
</body>

要填写申请表中的某些文字,您可以使用:

$(document).ready(function() {
  $("#txtEditor").Editor();
  $("#txtEditor").Editor("setText", <?php echo $value['details'];?>);
});