代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>KindEditor</title>
<style type="text/css" rel="stylesheet">
form {
margin: 0;
}
.editor {
margin-top: 5px;
margin-bottom: 5px;
}
</style>
<script type="text/javascript" charset="utf-8" src="./../kindeditor.js"></script>
<script type="text/javascript">
KE.show({
id : 'content1',
cssPath : './index.css'
});
</script>
</head>
<body>
<h3>默认模式</h3>
<form name="example" method="post" action="./../php/demo.php">
<div class="editor">
<textarea id="content1" name="content" style="width:700px;height:200px;visibility:hidden;">
<p>
之一。
</p>
</textarea>
</div>
<input type="button" name="button" value="取得内容" onclick="javascript:alert(KE.util.getData('content1'));" />
<input type="button" name="button" value="取得纯文本" onclick="javascript:alert(KE.util.getPureData('content1'));" />
<input type="submit" name="button" value="提交内容" />
</form>
</body>
</html>
这是提交的代码:
<?php
if (get_magic_quotes_gpc()) {
echo (stripslashes($_POST['content']));
} else {
echo $_POST['content'];
}
?>
问题是:onclick="javascript:alert(KE.util.getData('content1'));" 不需要对话框,如何进行保存, 保存文本或数据库怎么做?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>KindEditor</title>
<style type="text/css" rel="stylesheet">
form {
margin: 0;
}
.editor {
margin-top: 5px;
margin-bottom: 5px;
}
</style>
<script type="text/javascript" charset="utf-8" src="./../kindeditor.js"></script>
<script type="text/javascript">
KE.show({
id : 'content1',
cssPath : './index.css'
});
</script>
</head>
<body>
<h3>默认模式</h3>
<form name="example" method="post" action="./../php/demo.php">
<div class="editor">
<textarea id="content1" name="content" style="width:700px;height:200px;visibility:hidden;">
<p>
之一。
</p>
</textarea>
</div>
<input type="button" name="button" value="取得内容" onclick="javascript:alert(KE.util.getData('content1'));" />
<input type="button" name="button" value="取得纯文本" onclick="javascript:alert(KE.util.getPureData('content1'));" />
<input type="submit" name="button" value="提交内容" />
</form>
</body>
</html>
这是提交的代码:
<?php
if (get_magic_quotes_gpc()) {
echo (stripslashes($_POST['content']));
} else {
echo $_POST['content'];
}
?>
问题是:onclick="javascript:alert(KE.util.getData('content1'));" 不需要对话框,如何进行保存, 保存文本或数据库怎么做?
就是按你在php中怎麼對 textarea 取值一樣...
你這裡應該是這個编辑器的demo.他取值十分简单.$values=$_P["content"];
到对应from的action中找就看的到了.另外这个编辑器比较强大..你只要放好了路径.基本上是小问题了.另外他比fck还强大一点. fck跨不了chrome 它OK.
<input type="button" name="button" value="取得纯文本" onclick="javascript:alert(KE.util.getPureData('content1'));" />
这两句只是供测试用的,正式使用时是不要的表单有 action="./../php/demo.php"
所以接收提交的代码要写在 ../php/demo.php 中:
<?php
if (get_magic_quotes_gpc()) {
echo (stripslashes($_POST['content']));} else {
echo $_POST['content'];}
?>至于如何将 $_POST['content'] 的内容保存,已经不是编辑器的问题了。
任何表单都可能有需要保存的问题
$contnet = $_POST['content'];
下面是入库操作
这个是他的官网.你遇到什么问题都能在里面找到答案.