Ciao a tutti. Dovrei realizzare un pannello di amministrazione per
modificare i contenuti di un sito, e ho pensato di utilizzare tinyMCE. Ho
uno script con Ajax che una volta effettuata una scelta da un menù a
tendina, richiamo uno script PHP, il quale estrapola dei dati da un DB.
Quello che vorrei ottenere, è poter scrivere i risultati della query nella
textarea di tinyMCE, per poterli poi modificare e salvare nuovamente. Lo
script funziona correttamente, infatti riesco a scrivere i dati
all'interno di un DIV, cambiandoli dinamicamente tramite il menù a
tendina, senza dover ricaricare l'intera pagina. Il problema è che non
sono riuscito in alcun modo a scriverli nella textarea di tinyMCE. Eppure
so che è possibile farlo. Potete aiutarmi? Posto il codice:
<?php include("include/connection.inc.php");?>
<html>
<head>
<script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
// General options
editor_selector : "mceEditor",
editor_deselector : "mceNoEditor",
mode : "exact",
elements: "composizione",
theme : "advanced",
plugins :
"autolink,lists,spellchecker,pagebreak,style,layer ,table,save,advhr,advimage,advlink,emotions,iespel l,inlinepopups,insertdatetime,preview,media,search replace,print,contextmenu,paste,directionality,ful lscreen,noneditable,visualchars,nonbreaking,xhtmlx tras,template",
// Theme options
theme_advanced_buttons1 :
"save,newdocument,|,bold,italic,underline,striketh rough,|,justifyleft,justifycenter,justifyright,jus tifyfull,|,styleselect,formatselect,fontselect,fon tsizeselect",
theme_advanced_buttons2 :
"cut,copy,paste,pastetext,pasteword,|,search,repla ce,|,bullist,numlist,|,outdent,indent,blockquote,| ,undo,redo,|,link,unlink,anchor,image,cleanup,help ,code,|,insertdate,inserttime,preview,|,forecolor, backcolor",
theme_advanced_buttons3 :
"tablecontrols,|,hr,removeformat,visualaid,|,sub,s up,|,charmap,emotions,iespell,media,advhr,|,print, |,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 :
"insertlayer,moveforward,movebackward,absolute,|,s tyleprops,spellchecker,|,cite,abbr,acronym,del,ins ,attribs,|,visualchars,nonbreaking,template,blockq uote,pagebreak,|,insertfile,insertimage",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Skin options
skin : "o2k7",
skin_variant : "silver",
// Example content CSS (should be your site CSS) content_css :
"css/example.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "js/template_list.js",
external_link_list_url : "js/link_list.js",
external_image_list_url : "js/image_list.js",
media_external_list_url : "js/media_list.js",
// Replace values for the template plugin template_replace_values
: {
username : "Some User",
staffid : "991234"
}
});
</script>
<script type="text/javascript">
//ajax
function RecuperaDescrizione(str)
{
var xmlhttp;
if (str=="")
{
document.getElementById("composizione").innerHTML= ""; return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new
XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById
("composizione").innerHTML=xmlhttp.responseText ;
}
}
xmlhttp.open("GET","selectFromDatabase.php?q="+str ,true); xmlhttp.send();
}
</script>
</head>
<body>
<form action="">
<select name="sceltaProdotto" onchange="RecuperaDescrizione(this.value)">
<option value="">Seleziona un prodotto:</option> <option
value="Prodotto1">Prodotto1</option> <option
value="Prodotto2">Prodotto2</option> <option
value="Prodotto3">Prodotto3</option> </select>
<textarea name="composizione" style="width:50%"></textarea> </form>
</body>
</html>
Grazie in anticipo.
DRAGONET