[英]how to define ck-editor with id or class
My php file like this i am useing ck-editor in condition if i got $status > 0 than at that time display ck-editor otherwise it's display text box the problem is when my ck-editor name and text box name is same because i want to insert only one value which i get in post so i want to specify my ck-editor with id or class so i can get proper display and output 我这样的php文件,如果我得到$ status> 0的话,我正在使用ck-editor,比那时显示ck-editor否则它显示文本框的问题是当我的ck-editor名称和文本框名称相同时,因为我我只想插入一个我在帖子中得到的值,所以我想用id或class指定ck编辑器,这样我就可以正确显示和输出
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Settings
<small>Settings Edit</small>
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
<li class="active">Settings Edit</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<!-- Default box -->
<div class="box">
<div class="box box-primary">
<!-- form start -->
<form role="form" action="settingsedit.php" method="POST">
<input type="hidden" name="settings_id" value="<?php echo $settings_id; ?>">
<input type="hidden" name="settings_id" value="<?php echo $status; ?>">
<div class="box-body">
<div class="form-group">
<label for="exampleInputEmail1">Phone Number</label>
<?php
if($status > 0)
{
echo '<textarea name="settings" required>'.$value.'</textarea>';
}
else
{
echo '<input type="text" value="'.$value.'" name="settings">';
}
?>
</div>
<div class="box-footer">
<input type="submit" name="submit" class="btn btn-primary">
</div>
</form>
</div><!-- /.box-body -->
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
<?php include 'footer.php'; ?>
<script src="//cdn.ckeditor.com/4.4.7/standard/ckeditor.js"></script>
<script>CKEDITOR.replace('settings');</script>
CKEditor docs says the replace method takes an element
argument : CKEditor的文档说replace方法带有一个element
参数:
element : Object/String The DOM element (textarea), its ID, or name. element:Object / String DOM元素(文本区域),其ID或名称。
So, you can use document.getElementById
to select your textarea
and then use CKEditor.replace
upon it. 因此,您可以使用document.getElementById
选择您的textarea
,然后在其上使用CKEditor.replace
。
php/HTML : PHP / HTML:
<textarea id="mytextarea" name="settings" required><?php echo $value;?></textarea>
JS: JS:
var textarea = document.getElementById('mytextarea');
CKEditor.replace(textarea);
i got my answer simply give class of ckeditor and give id to that textarea and add that class in to ckeditor.. 我得到我的答案只是给ckeditor类,并给该textarea id,然后将该类添加到ckeditor中。
<textarea name="settings" class="ckeditor" id="test" required>'.$value.'</textarea>
<script>CKEDITOR.replace('#test');</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.