Skip to main content
Participating Frequently
November 8, 2016
Question

use mysql and javascript to update text

  • November 8, 2016
  • 1 reply
  • 364 views

I need to update text   in a captivate 9 project from a mysql database, i have tried using        an external xml file and javascript using this tutorial

httpS://forums.adobe.com/thread/1835737

I have also looked at the tutorial Common Javascript Interface in Adobe captivate 8 on youtube.

but can not find any sample code or tutorial.

can anyone help

CJ

    This topic has been closed for replies.

    1 reply

    TLCMediaDesign
    Inspiring
    November 8, 2016

    You're going to need to use AJAX and have a php file to query the DB.

    Participating Frequently
    November 14, 2016

    Hi Just a couple of questions,

    1.does this code work in a responsive project and publish to devices i.e.html 5?

    2. does it work without needing a button      press, I just want to display text on the first slide when project is open.

    3. would this work:

    var myArray = new object();

     

    if (window.XMLHttpRequest)

    {

    xmlhttp=new XMLHttpRequest();

    }

    else

    {

    xmlhttp.open("GET","testCase.php?q=",true);

    xmlhttp.send();

     

    window.cpAPIInterface.setVariableValue("testCase","");

     

    then the php would look like this:

    <?php

    require 'database        .php';

    $id=null;

    if (!empty ($_GET      ['id'])) {

    $id = $_REQUEST['id'];

    }

    if (null ==$id){

    header("Location:index.php");

    } else {

    $pdo->  setAttr       ibute(PDO::ATTR_ERRMODE_EXCEPTION);

    $sql = "SELECT  *   FROM drugs where id= ?";

    $q = $pdo_>prepare($sql);

    $q->execute (array($id));

    $data -$q->fetch(PDO;;FETCH_ASSOC);

    Database:: disconnect();

    }

    echo $data ['question1'];

    i'm not sure i've got the php quite right though.