Passing variables to certificate (in HTML5 version)

May 27, 2015

Since Storyline (1) does not support Print Results in HTML5 mode I decided to go for JavaScript to open up a printable certificate, but somehow the variables don't seem to get passed on to the certificate when using Internet Explorer (Firefox works fine though). Does anyone know how to fix this?

This is the JavaScript run in Storyline when the user clicks a "Print" hotspot:

var"report.html", "Kursintyg");

And this is the JavaScript that goes in the certificate (report.html):

var player=window.opener.GetPlayer();
var fornamn=player.GetVar("Förnamn").replace(/(\r\n|\r|\n)/g, '');
var efternamn=player.GetVar("Efternamn").replace(/(\r\n|\r|\n)/g, '');
document.write(""+fornamn+" "+efternamn+"");

I would be very grateful for help, as I've struggled a long time with this. Thank you. :)

3 Replies
Andreas Larsson

Hi Christine,

I am aware Articulate does not provide JavaScript support, but as printable certificates are something many users are likely to request I hoped the community had long since found a good general solution.

In any case, I solved it by modifying this script, which uses JavaScript to send the user variables to the certificate using POST (creating a temporary form). The variables are then read from the certificate using PHP.

The JavaScript run in Storyline when the user clicks the "Print" hotspot:

// Get user names
var player=GetPlayer();
var firstName=player.GetVar("Förnamn").replace(/(\r\n|\r|\n)/g, '');
var lastName=player.GetVar("Efternamn").replace(/(\r\n|\r|\n)/g, '');
var wholeNamn=firstName + " " + lastName;

// Create a form
var certificateForm = parent.document.createElement("form"); = "hiddenForm"; = "display:none;"; = "_blank";
certificateForm.method = "POST";
certificateForm.action = "report.php";

// Create an input
var certificateInput = parent.document.createElement("input");
certificateInput.type = "text"; = "variable";
certificateInput.value = wholeName;

// Add the input to the form

// Add the form to dom

// Just submit

The JavaScript that goes in the certificate (report.php):

<?php foreach ($_POST as $key => $value) echo htmlspecialchars($value); ?>

This discussion is closed. You can start a new discussion or contact Articulate Support.