MartinJ 0 Newbie Poster

Hi there, i have a bit of a problem with integrating CKeditor... I have a dynamic dropdown select box filled from MySQL, i have followed an Ajax tutorial on W3 schools http://www.w3schools.com/php/php_ajax_database.asp on how to get the selection pulled from MySQL to populate a textarea where it can then be edited, no problem there at all,
the problem starts when CKeditor is assigned to the textarea, when i select from the dropdown with an instance of CKeditor hooked to the <textarea> the field does not populate from MySQL, im guessing things need to be done in some kind of order (possibly even a delay while the instance sets itself up) does anyone have previous experience with this and can offer some advice on what to do. here is some code

here is the index.php

<?php
    $q="select id, name from templates order by name";
    $result=mysql_query($q);
    while(list($id, $name)=mysql_fetch_row($result)) {
        echo "<option value=\"".$id."\">".$name."</option>";
    }
    
    $qdata=$_GET["qdata"];

$q=("SELECT editor1 FROM templates WHERE id = '".$qdata."'");

$result = mysql_query($q);
while($row = mysql_fetch_array($result))
  {
  echo $row['editor1'];
  }
    
    ?>
</select>
<br />
<textarea id="editor1"></textarea>
 <script type="text/javascript">
                CKEDITOR.replace( 'editor1',
 {
     filebrowserBrowseUrl : 'ckfinder/ckfinder.html',
     filebrowserImageBrowseUrl : 'ckfinder/ckfinder.html?type=Images',
     filebrowserFlashBrowseUrl : 'ckfinder/ckfinder.html?type=Flash',
     filebrowserUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
     filebrowserImageUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
     filebrowserFlashUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
 } 
 );

            </script>

and here is the .js include file which is included within the <head> tags

var xmlhttp;

function showUser(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="index1.php";
url=url+"?qdata="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("editor1").innerHTML=xmlhttp.responseText;
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

i have also posted this in CKeditor forums (not holding out much hope though as help in there seems very sparse and the DOCs section a little on the lean side and confusing)
thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.