2013-06-26 39 views
0

嗯,我有這樣的代碼:

<?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獲得這個值。

謝謝!

回答

0

嗯,這是一段時間,但我會回答我發現的。也許它會在未來幫助別人。

我有同樣的問題,然後我發現你必須點擊「源」(查看HTML)和然後提交。如果沒有,它不會保存你寫的東西。不知道爲什麼會發生這種情況,我正在自己尋找這個問題的幫助。

0

您需要在窗體中添加.. onsubmit =「editor.post()」..以獲取wysiwyg編輯器的內容。 對於wysiwyg模式,iframe結構是動態構建的。處於wysiwyg模式時,textarea對象的值不會發生變化。只在源模式下。希望有所幫助。

0

試試這個工作對我來說:

<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>