亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何從 php 中的 suneditor textarea 發送值?

如何從 php 中的 suneditor textarea 發送值?

手掌心 2023-04-20 10:16:59
我想在 php Suneditor中發送 textarea 值PHP代碼if($_POST["submit"]){    $content =  $_POST["txtEditor"];    echo $content;}網頁代碼 <form action="" method="post" >        <textarea id="txtEditor" name="txtEditor" style="display:none;"></textarea>        <input type="submit" name="submit" class="submit">    </form>Javascript$(document).ready(function() {    $("#txtEditor").Editor();    $('form').submit(function () {        $('#txtEditor').val($('#txtEditor').Editor('getText'));    });    $('#txtEditor').Editor('setText', $('#txtEditor').val());});suneditor.create('txtEditor', {    buttonList: [        ['undo', 'redo', 'removeFormat'],        [align, font, fontSize, fontColor, hiliteColor],        [horizontalRule, image, template]    ],})編輯器工作完美。我哪里做錯了?
查看完整描述

6 回答

?
汪汪一只貓

TA貢獻1898條經驗 獲得超8個贊

完整代碼


const description = SUNEDITOR.create((document.getElementById('description')),{

            buttonList: [

                ['undo', 'redo'],

                ['bold', 'underline', 'italic'],

                ['removeFormat'],

                ['outdent', 'indent'],

                ['align', 'list'],

                ['table'],

                ['fullScreen', 'showBlocks']

            ],

            lang: SUNEDITOR_LANG['pl']

        });

        $(window).click(function() {

            document.getElementById('description').value = description.getContents();

        });


查看完整回答
反對 回復 2023-04-20
?
桃花長相依

TA貢獻1860條經驗 獲得超8個贊

您必須將值從 suneditor 發送到 textarea,您可以這樣做:

$(window).click(function() { 
           document.getElementById('txtEditor').value = txtEditor.getContents();
        });


查看完整回答
反對 回復 2023-04-20
?
慕村9548890

TA貢獻1884條經驗 獲得超4個贊

無需為此編寫任何 js 代碼,只需將您的文本/內容放在 textarea 標記之間,就像:


<textarea id="txtEditor" name="txtEditor" style="display:none;">Here is your text</textarea>

OR

<textarea id="txtEditor" name="txtEditor" style="display:none;">

   <?= $content; ?>

</textarea>


查看完整回答
反對 回復 2023-04-20
?
大話西游666

TA貢獻1817條經驗 獲得超14個贊

// Gets the suneditor's context object. Contains settings, plugins, and cached element objects


editor.getContext();


// Gets the contents of the suneditor

// onlyContents {Boolean}: Return only the contents of the body without headers when the "fullPage" option is true


editor.getContents(onlyContents: Boolean);    


// Gets only the text of the suneditor contents


editor.getText();


// Change the contents of the suneditor

editor.setContents('set contents');


查看完整回答
反對 回復 2023-04-20
?
收到一只叮咚

TA貢獻1821條經驗 獲得超5個贊

您只需要運行該instance.save()方法。


const instance = SUNEDITOR.create();

instance.save()


查看完整回答
反對 回復 2023-04-20
?
瀟瀟雨雨

TA貢獻1833條經驗 獲得超4個贊

您需要在 if 條件中使用 isset 函數,否則會拋出錯誤。


if(isset($_POST["submit"])){

    $content =  $_POST["txtEditor"];

    echo $content;

   }


查看完整回答
反對 回復 2023-04-20
  • 6 回答
  • 0 關注
  • 200 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號