【问题标题】:TinyEditor - using $_POSTTinyEditor - 使用 $_POST
【发布时间】:2013-06-24 04:04:08
【问题描述】:

好吧,我有这个代码:

<?php 
 if(isset($_POST['texto'])) {
 $texto =  $_POST['texto'];
echo "$texto";

 ?>
 <form action="/env_not.php" method="POST">
<textarea id="tinyeditor" name="texto" style="width: 700px; height: 800px"></textarea>
<script>
var editor = new TINY.editor.edit('editor', {
    id: 'tinyeditor',
    width: 700,
    height: 800,
    cssclass: 'tinyeditor',
    controlclass: 'tinyeditor-control',
    rowclass: 'tinyeditor-header',
    dividerclass: 'tinyeditor-divider',
    controls: ['bold', 'italic', 'underline', 'strikethrough', '|', 'subscript', 'superscript', '|',
        'orderedlist', 'unorderedlist', '|', 'outdent', 'indent', '|', 'leftalign',
        'centeralign', 'rightalign', 'blockjustify', '|', 'unformat', '|', 'undo', 'redo', 'n',
        'font', 'size', 'style', '|', 'image', 'hr', 'link', 'unlink', '|', 'print'],
    footer: true,
    fonts: ['Verdana','Arial','Georgia','Trebuchet MS'],
    xhtml: true,
    cssfile: 'custom.css',
    bodyid: 'editor',
    footerclass: 'tinyeditor-footer',
    toggle: {text: 'source', activetext: 'wysiwyg', cssclass: 'toggle'},
    resize: {cssclass: 'resize'}
});
</script>  <input type='submit' style='text-align: right' name='enviar' value='Enviar'>
  </form>

当我提交此表单时,我的 $_POST['texto'] 返回为空白,我如何将值传递到 TinyEditor 到我的 textarea.texto?因为我需要用 PHP 获取这个值。

谢谢!

【问题讨论】:

    标签: php javascript jquery post tinyeditor


    【解决方案1】:

    嗯,已经有一段时间了,但我会用我的发现来回答。也许将来会对某人有所帮助。

    我遇到了同样的问题,然后我发现您必须单击“源”(查看 html)并然后提交。如果没有,它不会保存你写的东西。不知道为什么会发生这种情况,我自己正在寻求有关此问题的帮助。

    【讨论】:

      【解决方案2】:

      您需要在表单中添加 .. onsubmit="editor.post()" .. 以获取所见即所得编辑器的内容。 对于所见即所得模式,动态构建 iframe 结构。在所见即所得模式下,您的 textarea-object 的值不会改变。仅在源模式下。希望有帮助。

      【讨论】:

        【解决方案3】:

        试试这个对我有用:

         <form action="/env_not.php" method="POST">
         <textarea id="texto" name="texto" style="width: 700px; height: 800px"></textarea>
         <script>
         var texto = new TINY.editor.edit('texto', {
          id: 'texto',
          width: 700,
          height: 800,
          cssclass: 'tinyeditor',
          controlclass: 'tinyeditor-control',
          rowclass: 'tinyeditor-header',
          dividerclass: 'tinyeditor-divider',
          controls: ['bold', 'italic', 'underline', 'strikethrough', '|', 'subscript', 'superscript', '|',
            'orderedlist', 'unorderedlist', '|', 'outdent', 'indent', '|', 'leftalign',
            'centeralign', 'rightalign', 'blockjustify', '|', 'unformat', '|', 'undo', 'redo', 'n',
            'font', 'size', 'style', '|', 'image', 'hr', 'link', 'unlink', '|', 'print'],
          footer: true,
          fonts: ['Verdana','Arial','Georgia','Trebuchet MS'],
          xhtml: true,
          cssfile: 'custom.css',
          bodyid: 'editor',
          footerclass: 'tinyeditor-footer',
          toggle: {text: 'source', activetext: 'wysiwyg', cssclass: 'toggle'},
          resize: {cssclass: 'resize'}
         });
         $('#enviar').click(function() {
           texto.post();
         });
        </script>  
        <input type='submit' style='text-align: right' name='enviar' id='enviar' value='Enviar'>
        </form>
        

        【讨论】:

          猜你喜欢
          • 2014-03-11
          • 1970-01-01
          • 2014-02-26
          • 2022-01-16
          • 2015-12-05
          • 1970-01-01
          • 2013-10-21
          • 2010-09-06
          相关资源
          最近更新 更多