doume5227 2016-10-30 03:50
浏览 47
已采纳

如何在CKEDITOR中启用和显示输入的数据?

In one of my webpage i have a CKEDITOR and two images containing 'onclick' events.When the page loads the editor is disabled.First: I want to enable the editor by pressing the first image having title "Allow edit".However this does not work.

My second problem is, i am not able to show alert message of the data entered into the editor when i remove the disabled attribute. The codes i'm using are given below.Please advise.Thank you.

<html>
<head>
<title>Test</title>
    <link href="../bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="../bower_components/metisMenu/dist/metisMenu.min.css" rel="stylesheet">
    <script src="../ckeditor/ckeditor.js"></script>
    <script src="../ckfinder/ckfinder.js"></script>
</head>
<body>
.......
.......
       <img src="../images/allow_edit.gif" alt="" onclick="enableEdit();" class="smallThreeButtons"  data-toggle="tooltip" data-placement="left" title="Allow edit"/>&nbsp;
       <img src="../images/modify_this.gif" alt="" onclick="saveEditData('txtAreaFullStoryP1');" class="smallThreeButtons"  data-toggle="tooltip" data-placement="bottom" title="Save modification"/>&nbsp;
       <textarea class="form-control" id="txtAreaFullStoryP1" disabled name="txtAreaFullStoryP1"></textarea>
       <script type="text/javascript">
            var editor = CKEDITOR.replace( 'txtAreaFullStoryP1', {
            filebrowserBrowseUrl : '../ckfinder/ckfinder.html',
            filebrowserImageBrowseUrl : '../ckfinder/ckfinder.html?type=Images',
            filebrowserFlashBrowseUrl : '../ckfinder/ckfinder.html?type=Flash',
            filebrowserUploadUrl : '../ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
            filebrowserImageUploadUrl : '../ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
            filebrowserFlashUploadUrl : '../ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
            });
            CKFinder.setupCKEditor( editor, '../' );
       </script>
       <script type="text/javascript">
           function enableEdit(cs){
            document.getElementById('txtAreaFullStoryP1').disabled='';//false <--not working
           }

           function saveEditData(ctrlNm){
                var ctrl_val = document.getElementById(ctrlNm).value;
                alert(ctrl_val);//<--not working, showing blank message
            }
       </script>
</body>
</html>
  • 写回答

2条回答 默认 最新

  • dousao6260 2016-10-30 06:29
    关注

    to remove disable

    document.getElementById('txtAreaFullStoryP1').removeAttribute('disabled');
    

    get textarea data in CKEDITOR

    var ctrl_val= CKEDITOR.instances['txtAreaFullStoryP1'].getData()
    alert( ctrl_val);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥500 我要找大模型一体机产品手册和应用案例
  • ¥60 用r语言进行数据分析
  • ¥20 关于游戏c++语言代码问题
  • ¥15 如何制作永久二维码,最好是微信也可以扫开的。(相关搜索:管理系统)
  • ¥15 delphi indy cookie 有效期
  • ¥15 labelme打不开怎么办
  • ¥35 按照图片上的两个任务要求,用keil5写出运行代码,并在proteus上仿真成功,🙏
  • ¥15 免费的电脑视频剪辑类软件如何盈利
  • ¥30 MPI读入tif文件并将文件路径分配给各进程时遇到问题
  • ¥15 pycharm中导入模块出错