CodeThatEditor Example - Editor Generation from the Database
<php
function create_definition($id) {
global $db;
$definition = "";
$result = mysql_query("select * from editor_data where id=$id");
if ($rs = mysql_fetch_array($result)) {
$definition = "text : '" . str_replace("\n", "<br>", $rs["note"]) . "'";
}
else {
$definition = "text : ''";
};
$definition = "var editorDef={" . $definition . ",
style : {
width : 400,
height : 200,
defaultClass: 'defaultcss'
}
}";
return $definition;
};
if (empty($id)) $id = 1;
?>
<html>
<head>
<title>Editor Test</title>
<link href="/common_codethat.css" rel="stylesheet" type="text/css">
<script language="javascript1.2" src="codethatsdk.js"></script>
<script language="javascript" src="codethateditorpro.js"></script>
<script language="javascript1.2">
<!--
<?php print(create_definition($id)); ?>
//-->
</script>
<style>
.defaultcss{
background-color:"#ffffff",
border-color:"#efefe0",
border-style:"inset", border-width:2}
</style>
</head>
<body>
<script language="javascript1.2">
<!--
var CodeThatEditor = new CEditor("Editor", editorDef);
CodeThatEditor.create();
//-->
</script>
<form>
Note # <input type=text name=id value="<?php
print($id);
?>">
<input type=submit value="Read note">
</form>
|