Jump to content

Recommended Posts

HOw I can load the content for the area from a database using a dropdown menu? I try but i cant makeit o work...

 

heres the sample code from tinymce wiki...

 

tinyMCE.init({
mode : "textareas",
theme : "advanced"
});

function ajaxLoad() {
var inst = tinyMCE.getInstanceById('content');

// Do you ajax call here
inst.setHTML('HTML content that got passed from server.');
}

function ajaxSave() {
var inst = tinyMCE.getInstanceById('content');

// Do you ajax call here
alert(inst.getHTML());
}

Link to comment
https://forums.phpfreaks.com/topic/72886-phpajaxmysql-and-tinymce/
Share on other sites

This is my code...Im using radio buttons...

 

<!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>Manejador de Contenidos</title>

<?php
require_once("../include/header.inc.php");
require_once( DIRECTORY_PATH_INC . 'utils.inc.php');
require_once( DIRECTORY_PATH_INC . 'db.inc.php');

global $contenido;


function LoadGreeting(){
$contenido = "Este es el Manejador de Contenidos de su Pagina Seleccione del Menu";
echo $contenido;
}

function ContentLoad(){
echo $_POST['Categories'];
if ($_POST['Categories'] = "Main Page")
$category = "Main Page";
if ($_POST['Categories'] = "Tour")
$category = "Tour";

echo $category;	
$query = "SELECT `Contenido` FROM `Content` WHERE `Category` = '$category'";
$contenido = db_value($query);
echo $contenido;

}

function SaveContent2(){

$query = "UPDATE `Content` SET `Contenido`= '$newContent' WHERE `ID` = 1";
$greeting = db_res($query);
echo "Contenido Guardado";

}

?>

<script type="text/javascript" src="../plugins/tiny_mce/tiny_mce_src.js"></script>
<script language="javascript" type="text/javascript">
	tinyMCE.init({
		mode : "textareas",
		theme : "advanced",
		plugins : "fullpage",
	    theme_advanced_buttons3_add : "fullpage"
	});

function Load() {
var inst = tinyMCE.getInstanceById('content');
  inst.setHTML('<?php ContentLoad();?>');
}

function Save() {
var inst = tinyMCE.getInstanceById('content');
tinyMCE.triggerSave(true,true);
//alert(inst.getHTML()); 
}

function saveContent(content, id) {
	alert('The content for "' + id + '" has been saved');
	http.open("GET", "save_content.php?id=" + id + "&content=" + escape(content), true);
	http.onreadystatechange = handleHttpResponse(id);
	http.send(null);
}    
</script>


</head>

<body>

<form id="form1" name="form1" method="post" action="">
  <p>
    <label>
      <input type="radio" name="Categories" value="Main Page" id="Categories_0" />
      Main Page</label>
    <br />
    <label>
      <input type="radio" name="Categories" value="Tour" id="Categories_1" />
      Tour</label>
    <br />
  </p>
<input type="button" value="Cargar" onclick="Load();" />
<input name="Reset" type="reset" value="Comenzar de Nuevo" />
</form>

<textarea id="content" name="content" cols="85" rows="25" class="mceAdvanced"><?php LoadGreeting();?></textarea><br />
      
	<input type="button" value="Save" onclick="saveContent(inst.getHTML(), 1)" />


<!--<form method="post" action="edit_content.php">

        
      name="cat"  onclick="Load();"
         <input type="button" value="Load" onclick= "Load();" />
        <textarea name="index_content" cols="90" rows="15">Wooo This is some content that will be editable with TinyMCE.</textarea>
	<input type="submit" value="Submit" />
  </form> -->

</body>
</html>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.