troubleshooting Question

TinyMCE Ajax autoload html content

Avatar of Abrasax7
Abrasax7 asked on
JavaScriptPHPAJAX
6 Comments1 Solution1975 ViewsLast Modified:
Hello guys, thanks in advance for your help.

For a email programm I am currently working on I am using TinyMCE to show templates (stored in MySQL database) that have been saved in advance. I currently have a dropdownlist for these templates which is generated like so:

=================drop down list====================

$r2 = mysqli_query ($dbc, 'SELECT * FROM templates ORDER BY template_title');
            while ($row2 = mysqli_fetch_array ($r2, MYSQLI_NUM)) {
                  if ($row2[0] == $row['user_id']) {
                        echo "<option value=\"$row2[0]\" selected=\"selected\">$row2[1]</option>\n";
                  } else {
                        echo "<option value=\"$row2[0]\">$row2[1]</option>\n";
                  }
            }

=================/drop down list====================

what I want is that whenever I chose a template from the dropdown list the content is autopopulated into the tinymce textarea. The following link shows this concept
http://www.tinymce.com/tryit/ajax_load_save.php

I can retrieve the template content from my database like so:

=================Template content====================

      $query = "SELECT template_title, template_content FROM templates WHERE template_id={$_GET['id']}";
      if ($r = mysqli_query($dbc, $query)) { // Run the query.
      
            $row = mysqli_fetch_array($r); // Retrieve the information.


$row['template_content']

=================/Template content====================

In the link I posted above they use the function

function ajaxLoad() {
        var ed = tinyMCE.get('content');

        // Do you ajax call here, window.setTimeout fakes ajax call
        ed.setProgressState(1); // Show progress
        window.setTimeout(function() {
                ed.setProgressState(0); // Hide progress
                ed.setContent('HTML content that got passed from server.');
        }, 2000);
}

to load the content, and have a load button "<a href="javascript:;" onclick="ajaxLoad();return false;"><span>Load</span></a>"

How can I make this work with a dropdownlist that works with my database


thankyou
ASKER CERTIFIED SOLUTION
Julian Matz
Technical Support
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros