Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Problem updating Captivate results to database using coldfusion

Posted on 2007-10-10
19
Medium Priority
?
788 Views
Last Modified: 2013-12-24
I created a quiz in captivate and would like to store results in a database.  I followed a tutorial to accomplish this task but it's giving me a database query error.   The code for the quiz with the java script is
:

<!-- saved from url=(0013)about:internet -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>talkingtoparentsquiz</title>
<script type="text/javascript">
<!-- Begin
var gstrEmailTo = "";
var gstrEmailSubject = "";
var gstrEmailBody = "";
var myVar = 0;

function appendEmailBody(strBody)
{
      var temp_str = strBody;
      while(temp_str.indexOf("|") > -1)
      {
            temp_str = temp_str.substr(0,temp_str.indexOf("|")) + "\r" + temp_str.substr(temp_str.indexOf("|") + 1)
      }
      gstrEmailBody += temp_str + "\r";
}

function sendMail()
{

      // strip the word Core Data out of the results
      var stripCoreData = gstrEmailBody.replace("Core Data", "");
      // remove the double quotes
      var stripQuotes = stripCoreData;
      while(stripQuotes.indexOf("\"") !=-1){
      stripQuotes=stripQuotes.replace("\"", "");
      }
      // turn results into an array to access single items
      var results_array = stripQuotes.split(",");

      // assign variables
      var RawScore = results_array[7];
      var MaxScore = results_array[8];
      var MinScore = results_array[9];
      var Accuracy = RawScore/MaxScore;
      Accuracy = Accuracy*100;

// write html for popup window
var htmlString=
"<html><head><title>Email Results</title></head><body>" +
"<form Name='results' method='post' action='insert.cfm'>" +
"<table cellspacing=1 cellpadding=4 border=0><tr><td bgcolor='#336699'><strong>Your score:</strong></td>" +
"<td align='left' bgcolor='#6699cc'>" + RawScore + "</td></tr>"+
"<tr><td bgcolor='#336699'><strong>Maximum score:</strong></td>"+
"<td align='left' bgcolor='#6699cc'>" + MaxScore      + "</td></tr>" +
"<tr><td bgcolor='#336699'><strong>Accuracy:</strong></td>" +
"<td align='left' bgcolor='#6699cc'>" + Accuracy + "%</td></tr>" +
"<tr><td bgcolor='#336699'><strong>Your Name:</strong></td><td align='left' bgcolor='#6699cc'><input type='text' Name='name'></td></tr>" + "<tr><td bgcolor='#336699'><strong>Email Address:</strong></td><td align='left' bgcolor='#6699cc'><input type='text' Name='email'></td></tr>" + "<tr><td bgcolor='#336699'>" +
"<input type='hidden' value='robodemo' name='Test'>" +
"<input type='hidden' value='" + MaxScore + "' name='total'>" +
"<input type='hidden' value='" + RawScore + "' name='correct'>" +
"<input type='hidden' value='" + Accuracy + "' name='accuracy'>" +
"</td><td align='left' bgcolor='#6699cc'><input type='submit' name='Submit' value='Submit Your Score'></td></tr></table>" +
"</form></body></html>"

// function for the popup window
      function launchwin(htmlString){
         newwin = window.open("","flashcamwin","height=700,width=700,scrollbars=0");
         newwin.document.open();
         newwin.document.write(htmlString);
         newwin.document.close();
}

// launch the window
    launchwin(htmlString);

}


function padMail(strAddress, strSubject, strBody)
{
      gstrEmailTo = strAddress;
      gstrEmailSubject = strSubject;
      var temp_str = strBody;
      while(temp_str.indexOf("|") > -1)
      {
            temp_str = temp_str.substr(0,temp_str.indexOf("|")) + "\r" + temp_str.substr(temp_str.indexOf("|") + 1)
      }
      gstrEmailBody = temp_str + "\r";
}
// End -->
</script>

<form name="emailForm" action = "" method="POST" enctype="text/plain">
<input name="Results" type="hidden">
</form>
</head>

<body>
<center>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="650" height="487" ID="Captivate1">
  <param name="movie" value="talkingtoparentsquiz.swf">
  <param name="quality" value="high">
  <param name="menu" value="false">
  <param name="loop" value="0">
  <embed src="talkingtoparentsquiz.swf" width="650" height="487" loop="0" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false"></embed>
</object>
</center>
</body>
</html>

////////////////////////////////////////////////////////
The code for the inserting the results in the database is :

<cfquery datasource="myQuiz" name="insertData">
  INSERT INTO robodemo (total, correct, accuracy, name, email)
  VALUES (
  <cfif IsDefined("FORM.total") AND #FORM.total# NEQ "">
    '#FORM.Total#'
      <cfelse>
      NULL
  </cfif>
  ,
  <cfif IsDefined("FORM.correct") AND #FORM.correct# NEQ "">
    #FORM.correct#
      <cfelse>
      NULL
  </cfif>
  ,
  <cfif IsDefined("FORM.accuracy") AND #FORM.accuracy# NEQ "">
    '#FORM.accuracy#'
      <cfelse>
      NULL
  </cfif>
  ,
  <cfif IsDefined("FORM.name") AND #FORM.name# NEQ "">
    '#FORM.name#'
      <cfelse>
      NULL
  </cfif>

THE ERROR THAT I'M GETTING IS THIS.

Error Executing Database Query.  
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.  

Can you help me with this ?
0
Comment
Question by:mattphung
  • 10
  • 8
19 Comments
 
LVL 53

Expert Comment

by:_agx_
ID: 20053753
One cause of that error is forgetting to put single quotes around a string value (ie "this is a string").  

For example, if the data type of the "correct" column were "text",  you must put single quotes around the form field.  

 <cfif IsDefined("FORM.correct") AND #FORM.correct# NEQ "">
    <!--- notice the single quotes here --->
    '#FORM.correct#'
  <cfelse>
      NULL
  </cfif>

0
 
LVL 6

Expert Comment

by:reitzen
ID: 20054607
In the section you have specified for "inserting the results in the database", you are missing the "EMAIL" value.  You have five (5) fields listed in the INSERT statement:

INSERT INTO robodemo (total, correct, accuracy, name, email)

, yet you only have four (4) values available fore the insert.

Add the <CFIF...> for the EMAIL field and you should be good to go.

As a side note, there are ways you can simplify and more securely write your code by using tags such as the <CFPARAM...> with/without a scope (FORM, URL, etc), and/or <CFQUERYPARAM...> (highly recommended to prevent SQL injections).  Post a reply if you would like more info.

HTH, Rob
0
 
LVL 53

Expert Comment

by:_agx_
ID: 20057041
> In the section you have specified for "inserting the results in the database", you are missing
> the "EMAIL" value.  You have five (5) fields listed in the INSERT statement:

    That's true, but it looks the code is from the error message, which may or may not include
    the full query.   Access would return a different error message if the number of columns
    in the INSERT list was different than the number of values in the VALUES statement.

> <CFQUERYPARAM...> (highly recommended to prevent SQL injections).
 
   I suspect the code was automatically generated by an IDE.  But yes, <cfqueryparam>
   is recommended.  It also has other benefits.  For example, you don't have to worry about
   single quoting string values.  <cfqueryparam> handles it automatically. It also supports the
   "null" attribute. So instead of writing this

 <cfif IsDefined("FORM.total") AND #FORM.total# NEQ "">
    '#FORM.Total#'
      <cfelse>
      NULL
  </cfif>
           
You could use <cfparam> to define a default for all your form variables

     <!--- ensure that form.total always exists --->
    <cfparam name="form.total" default="" />
    <cfparam name="form.correct" default="" />
    ... etc ...

Then use <cfqueryparam> in your INSERT statement

    INSERT INTO robodemo (total, correct, accuracy, name, email)
    VALUES
    (
     <!--- if form.total is empty, NULL will be inserted --->
    <cfqueryparam value="#form.total#" cfsqltype="cf_sql_varchar" null="#not len(trim(form.total))#" />,
    ... other fields ...
    )


0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mattphung
ID: 20076426
After correcting the quotes for string values only I still get the  error
Error Executing Database Query.  
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.  

Do I have to have the variables defined in the quiz page?

<cfquery datasource="myQuiz" name="insertData">
  INSERT INTO robodemo (total, correct, accuracy, name, email)
  VALUES (
  <cfif IsDefined("FORM.total") AND #FORM.Total# NEQ "">
    #FORM.total#
      <cfelse>
      NULL
  </cfif>
  ,
  <cfif IsDefined("FORM.correct") AND #FORM.correct# NEQ "">
    #FORM.correct#
      <cfelse>
      NULL
  </cfif>
  ,
  <cfif IsDefined("FORM.accuracy") AND #FORM.Accuracy# NEQ "">
    #FORM.accuracy#
      <cfelse>
      NULL
  </cfif>
  ,
  <cfif IsDefined("FORM.name") AND #FORM.Name# NEQ "">
    '#FORM.name#'
      <cfelse>
      NULL
  </cfif>
  ,
  <cfif IsDefined("FORM.email") AND #FORM.Email# NEQ "">
    '#FORM.email#'
      <cfelse>
      NULL
  </cfif>
  )
  </cfquery>
  <html>
0
 
LVL 53

Expert Comment

by:_agx_
ID: 20078478
> Do I have to have the variables defined in the quiz page

1.  Not necessarily.  The form field variables  FORM.total, FORM.email, etc... should be created automatically when you submit the form.  Can you post your quiz page form code?

2. Open your Access database.  What are the data types of each of these columns:
  total
  correct,
  accuracy,
  name,
  email

(text, number, ...?)
0
 

Author Comment

by:mattphung
ID: 20079316
Here's the code I have for the quiz page.

<!-- saved from url=(0013)about:internet -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>talkingtoparentsquiz</title>
<script type="text/javascript">
<!-- Begin
var gstrEmailTo = "";
var gstrEmailSubject = "";
var gstrEmailBody = "";
var myVar = 0;

function appendEmailBody(strBody)
{
      var temp_str = strBody;
      while(temp_str.indexOf("|") > -1)
      {
            temp_str = temp_str.substr(0,temp_str.indexOf("|")) + "\r" + temp_str.substr(temp_str.indexOf("|") + 1)
      }
      gstrEmailBody += temp_str + "\r";
}

function sendMail()
{

      // strip the word Core Data out of the results
      var stripCoreData = gstrEmailBody.replace("Core Data", "");
      // remove the double quotes
      var stripQuotes = stripCoreData;
      while(stripQuotes.indexOf("\"") !=-1){
      stripQuotes=stripQuotes.replace("\"", "");
      }
      // turn results into an array to access single items
      var results_array = stripQuotes.split(",");

      // assign variables
      var RawScore = results_array[7];
      var MaxScore = results_array[8];
      var MinScore = results_array[9];
      var Accuracy = RawScore/MaxScore;
      Accuracy = Accuracy*100;

// write html for popup window
var htmlString=
"<html><head><title>Email Results</title></head><body>" +
"<form Name='results' method='post' action='insert.cfm'>" +
"<table cellspacing=1 cellpadding=4 border=0><tr><td bgcolor='#336699'><strong>Your score:</strong></td>" +
"<td align='left' bgcolor='#6699cc'>" + RawScore + "</td></tr>"+
"<tr><td bgcolor='#336699'><strong>Maximum score:</strong></td>"+
"<td align='left' bgcolor='#6699cc'>" + MaxScore      + "</td></tr>" +
"<tr><td bgcolor='#336699'><strong>Accuracy:</strong></td>" +
"<td align='left' bgcolor='#6699cc'>" + Accuracy + "%</td></tr>" +
"<tr><td bgcolor='#336699'><strong>Your Name:</strong></td><td align='left' bgcolor='#6699cc'><input type='text' Name='name'></td></tr>" + "<tr><td bgcolor='#336699'><strong>Email Address:</strong></td><td align='left' bgcolor='#6699cc'><input type='text' Name='email'></td></tr>" + "<tr><td bgcolor='#336699'>" +
"<input type='hidden' value='robodemo' name='Test'>" +
"<input type='hidden' value='" + MaxScore + "' name='total'>" +
"<input type='hidden' value='" + RawScore + "' name='correct'>" +
"<input type='hidden' value='" + Accuracy + "' name='accuracy'>" +
"</td><td align='left' bgcolor='#6699cc'><input type='submit' name='Submit' value='Submit Your Score'></td></tr></table>" +
"</form></body></html>"
// function for the popup window
      function launchwin(htmlString){
         newwin = window.open("","flashcamwin","height=700,width=700,scrollbars=0");
         newwin.document.open();
         newwin.document.write(htmlString);
         newwin.document.close();
}

// launch the window
    launchwin(htmlString);

}


function padMail(strAddress, strSubject, strBody)
{
      gstrEmailTo = strAddress;
      gstrEmailSubject = strSubject;
      var temp_str = strBody;
      while(temp_str.indexOf("|") > -1)
      {
            temp_str = temp_str.substr(0,temp_str.indexOf("|")) + "\r" + temp_str.substr(temp_str.indexOf("|") + 1)
      }
      gstrEmailBody = temp_str + "\r";
}
// End -->
</script>

<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<form name="emailForm" action = "" method="POST" enctype="text/plain">
<input name="Results" type="hidden">
</form>
</head>

<body>
<center>
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0','width','650','height','487','id','Captivate1','src','talkingtoparentsquiz','loop','0','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','menu','false','movie','talkingtoparentsquiz' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="650" height="487" ID="Captivate1">
  <param name="movie" value="talkingtoparentsquiz.swf">
  <param name="quality" value="high">
  <param name="menu" value="false">
  <param name="loop" value="0">
  <embed src="talkingtoparentsquiz.swf" width="650" height="487" loop="0" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false"></embed>
</object></noscript>
</center>
</body>
</html>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
The data types for the table are : test (text), total (number), correct (number), attempts (number), steps (number), accuracy (number), name (text) and email (text).
0
 
LVL 53

Expert Comment

by:_agx_
ID: 20079490
> The data types for the table are :

The quoting seems correct for those data types. Though you should consider using <cqueryparam>

If full debugging is enabled, the error message should include the sql statement that was sent to the database.  Could you post that sql here?

0
 

Author Comment

by:mattphung
ID: 20079658
This is the debugging error I get in the exceptions box.

09:59:25.025 - Database Exception - in C:\CFusionMX7\wwwroot\oxfordemployee\insert.cfm : line 32
          Error Executing Database Query.
0
 
LVL 53

Expert Comment

by:_agx_
ID: 20079839
If you can't find the statement, add this to the insert page _before_ the query. It will reconstruct the sql statement


The sql query sent to the database is:<br>
<cfoutput>
  INSERT INTO robodemo (total, correct, accuracy, name, email)
  VALUES (
  <cfif IsDefined("FORM.total") AND #FORM.Total# NEQ "">
    '#FORM.total#'
      <cfelse>
      NULL
  </cfif>
  ,
  <cfif IsDefined("FORM.correct") AND #FORM.correct# NEQ "">
    #FORM.correct#
      <cfelse>
      NULL
  </cfif>
  ,
  <cfif IsDefined("FORM.accuracy") AND #FORM.Accuracy# NEQ "">
    #FORM.accuracy#
      <cfelse>
      NULL
  </cfif>
  ,
  <cfif IsDefined("FORM.name") AND #FORM.Name# NEQ "">
    '#FORM.name#'
      <cfelse>
      NULL
  </cfif>
  ,
  <cfif IsDefined("FORM.email") AND #FORM.Email# NEQ "">
    '#FORM.email#'
      <cfelse>
      NULL
  </cfif>
  )
<cfoutput>
<hr>
0
 

Author Comment

by:mattphung
ID: 20080710
Here's the SQL query.  It's still gives me an error for the query at line 32 which is the closing </cfif> tag.
/////////////////////////////////////////////////////////////////////////////////////////////
SQL Queries

insertData (Datasource=myQuiz, Time=0ms, Records=0) in C:\CFusionMX7\wwwroot\oxfordemployee\insert.cfm @ 12:04:12.012

  INSERT INTO robodemo(total, correct, accuracy, name, email)
  VALUES (
 
      NULL
 
  ,
 
      NULL
 
  ,
 
      NULL
 
  ,
 
      NULL
 
  ,
 
      NULL
 
  )

0
 
LVL 53

Expert Comment

by:_agx_
ID: 20080814
There's a typo. The last few lines should be
    ...
     )
    </cfoutput>
    <hr>

instead of
    ...
     )
   <cfoutput>
    <hr>

But it looks like you ran the insert page by itself.  Can you use your form, so I can see the values that generate the query error:

[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.  
0
 

Author Comment

by:mattphung
ID: 20080986
The javascript in my quiz page pulls up a window that allows the user to add in their name and email address.  I do get an undefined text for the "Your Score" and "Maximum Score" fields.  Once they enter their information then I would get the error:

Error Executing Database Query.  
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.  

Database Exception - in C:\CFusionMX7\wwwroot\oxfordemployee\insert.cfm : line 32
          Error Executing Database Query
0
 
LVL 53

Expert Comment

by:_agx_
ID: 20081065
>  I do get an undefined text for the "Your Score" and "Maximum Score" fields.  

Did you follow the same steps you used when you got the error the first time? I can't see your quiz, and I'm not familiar with Captivate so I can't really offer you any advice there.

> Once they enter their information then I would get the error:

Okay, but if you add the code I posted to the insert page _before_ the cfquery code, you should be able to see the sql statement _before_ that error message appears.
0
 

Author Comment

by:mattphung
ID: 20081693
I added and ran the <cfoutput> code from the insert file and it gives me  the following SQL below.  When I complete the quiz and fill out the form it has a problem opening the insert page.

SQL Queries

insertData (Datasource=myQuiz, Time=0ms, Records=0) in C:\CFusionMX7\wwwroot\oxfordemployee\insert.cfm @ 14:26:13.013

  INSERT INTO robodemo(total, correct, accuracy, name, email)
  VALUES (
 
      NULL
 
  ,
 
      NULL
 
  ,
 
      NULL
 
  ,
 
      NULL
 
  ,
 
      NULL
 
  )

0
 
LVL 53

Expert Comment

by:_agx_
ID: 20082588
> When I complete the quiz and fill out the form it has a problem opening the insert page.

   What kind of error, javascript, ColdFusion..?


Let's try a different approach: testing your cfquery with some sample values.   Place this code in your "insert.cfm" file and run it.  I tested it against an access db, using the column types you provided, so it should work fine.

INSERT.CFM PAGE:

   <!--- these are sample values. use for testing/debugging purposes only --->
   <!---start:  remove these values when you've when finished testing: --->
   <cfset form.total = 10>
   <cfset form.correct = 8>
   <cfset form.accuracy = 80>
   <cfset form.name = "test one">
   <cfset form.email = "testemail@somecompany.com">
   <!---end:  remove these values when you've when finished testing: --->
   

   <cfquery datasource="myQuiz" name="insertData">
     INSERT INTO robodemo (total, correct, accuracy, name, email)
     VALUES
     (
        <cfqueryparam value="#form.total#" cfsqltype="cf_sql_integer" null="#not isNumeric(form.total)#">
        ,
        <cfqueryparam value="#form.correct#" cfsqltype="cf_sql_integer" null="#not isNumeric(form.correct)#">
        ,
        <cfqueryparam value="#form.accuracy#" cfsqltype="cf_sql_integer" null="#not isNumeric(form.accuracy)#">
        ,
        <cfqueryparam value="#form.Name#" cfsqltype="cf_sql_varchar" null="#not len(trim(form.name))#">
        ,
        <cfqueryparam value="#form.email#" cfsqltype="cf_sql_varchar" null="#not len(trim(form.email))#">
     )
   </cfquery>
0
 

Author Comment

by:mattphung
ID: 20083516
Yes! Your approach works. I tested the cfset values and they are posted in the database.  After testing I removed the temp variables and ran the quiz.  The quiz would post the name and email but would not send any values.  I not sure why.  Do I need to correct the javascript in the quiz?
0
 
LVL 53

Expert Comment

by:_agx_
ID: 20086756
Yes, it does seem like the query error is fixed and this is a different problem with the javascript form code.  Keep in mind I'm not familiar with Captivate, so I'm just guessing.

You could put a cfdump statement at the top of the insert.cfm page (before the query).  
     <cfdump var="#FORM#">

When you submit the quiz form, CF will show all of the form fields that were posted.  Check the field names. If you only see "name" and "email" (not the other fields) then its suggests a problem with the javascript used to generate your form.
0
 

Author Comment

by:mattphung
ID: 20086874
I used <cfdump> and it gives me a result of :
ACCURACY NaN  
CORRECT undefined  
EMAIL      anthony2  
FIELDNAMES       NAME,EMAIL,TEST,TOTAL,CORRECT,ACCURACY,SUBMIT  
NAME    asdfasdf  
SUBMIT    Submit Your Score  
TEST   robodemo  
TOTAL   undefined  
Some how the javascript in my orignial quiz is not defining the number correct, total,  and accuracy.
The current code for the quiz is :

var gstrEmailTo = "";
var gstrEmailSubject = "";
var gstrEmailBody = "";
var myVar = 0;

function appendEmailBody(strBody)
{
      var temp_str = strBody;
      while(temp_str.indexOf("|") > -1)
      {
            temp_str = temp_str.substr(0,temp_str.indexOf("|")) + "\r" + temp_str.substr(temp_str.indexOf("|") + 1)
      }
      gstrEmailBody += temp_str + "\r";
}

function sendMail()
{

      // strip the word Core Data out of the results
      var stripCoreData = gstrEmailBody.replace("Core Data", "");
      // remove the double quotes
      var stripQuotes = stripCoreData;
      while(stripQuotes.indexOf("\"") !=-1){
      stripQuotes=stripQuotes.replace("\"", "");
      }
      // turn results into an array to access single items
      var results_array = stripQuotes.split(",");

      // assign variables
      var RawScore = results_array[7];
      var MaxScore = results_array[8];
      var MinScore = results_array[9];
      var Accuracy = RawScore/MaxScore;
      Accuracy = Accuracy*100;

// write html for popup window
var htmlString=
"<html><head><title>Email Results</title></head><body>" +
"<form Name='results' method='post' action='insert.cfm'>" +
"<table cellspacing=1 cellpadding=4 border=0><tr><td bgcolor='#336699'><strong>Your score:</strong></td>" +
"<td align='left' bgcolor='#6699cc'>" + RawScore + "</td></tr>"+
"<tr><td bgcolor='#336699'><strong>Maximum score:</strong></td>"+
"<td align='left' bgcolor='#6699cc'>" + MaxScore      + "</td></tr>" +
"<tr><td bgcolor='#336699'><strong>Accuracy:</strong></td>" +
"<td align='left' bgcolor='#6699cc'>" + Accuracy + "%</td></tr>" +
"<tr><td bgcolor='#336699'><strong>Your Name:</strong></td><td align='left' bgcolor='#6699cc'><input type='text' Name='name'></td></tr>" + "<tr><td bgcolor='#336699'><strong>Email Address:</strong></td><td align='left' bgcolor='#6699cc'><input type='text' Name='email'></td></tr>" + "<tr><td bgcolor='#336699'>" +
"<input type='hidden' value='robodemo' name='Test'>" +
"<input type='hidden' value='" + MaxScore + "' name='total'>" +
"<input type='hidden' value='" + RawScore + "' name='correct'>" +
"<input type='hidden' value='" + Accuracy + "' name='accuracy'>" +
"</td><td align='left' bgcolor='#6699cc'><input type='submit' name='Submit' value='Submit Your Score'></td></tr></table>" +
"</form></body></html>"

// function for the popup window
      function launchwin(htmlString){
         newwin = window.open("","flashcamwin","height=300,width=325,scrollbars=0");
         newwin.document.open();
         newwin.document.write(htmlString);
         newwin.document.close();
}

// launch the window
    launchwin(htmlString);

}

function padMail(strAddress, strSubject, strBody)
{
      gstrEmailTo = strAddress;
      gstrEmailSubject = strSubject;
      var temp_str = strBody;
      while(temp_str.indexOf("|") > -1)
      {
            temp_str = temp_str.substr(0,temp_str.indexOf("|")) + "\r" + temp_str.substr(temp_str.indexOf("|") + 1)
      }
      gstrEmailBody = temp_str + "\r";
}
// End -->
</script>

<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<form name="emailForm" action = "" method="POST" enctype="text/plain">
<input name="Results" type="hidden">
</form>
</head>

<body>
<center>
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0','width','650','height','487','id','Captivate1','src','talkingtoparentsquiz','loop','0','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','menu','false','movie','talkingtoparentsquiz' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="650" height="487" ID="Captivate1">
  <param name="movie" value="talkingtoparentsquiz.swf">
  <param name="quality" value="high">
  <param name="menu" value="false">
  <param name="loop" value="0">
  <embed src="talkingtoparentsquiz.swf" width="650" height="487" loop="0" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false"></embed>
</object></noscript>
</center>
</body>
</html>

Do I need to adjust the variables for htmlString?
0
 
LVL 53

Accepted Solution

by:
_agx_ earned 500 total points
ID: 20086985
> Do I need to adjust the variables for htmlString?

I don't know. If its a sample from a tutorial then I'll assume its supposed to work.  Perhaps you changed something in the code?

I can see what I think is the problem.  One of the javascript functions is taking a comma delimited string of values, and extracting each piece into an array here:
      // assign variables
      var RawScore = results_array[7];
      var MaxScore = results_array[8];
      var MinScore = results_array[9];
      var Accuracy = RawScore/MaxScore;
      Accuracy = Accuracy*100;

But the function isn't able to find/extract some of the values.  That's why you're seeing "undefined" on the insert.cfm page.  If you've accidentally overwritten some of the code, you might try using a fresh copy of the tutorial code.  

Sorry, I can't help you more with the Captivate stuff.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
Microsoft Jet database engine errors can crop up out of nowhere to disrupt the working of the Exchange server. Decoding why a particular error occurs goes a long way in determining the right solution for it.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question