Forum Discussion
Help with Course Variables in HTML document
Non-coder desperately seeking help... Don't know WHERE/WHAT code to type into HTML file to pull variables from storyline. First, big thanks to all for posted solutions that have gotten me this far!
I have a 3-page form users need to "sign" electronically (name, job title, date) and print with variables embedded in the html output, and post results to LMS. I did this once using a quiz by pasting an image of the form in the background of the results slide with variables positioned accordingly and using some basic "print" javascript I found.
BUT... this one's 3-pages, a simple 1-page certificate and print command won't work. My original form was in Word, so I saved it as BlankForm.html. I saved two additional copies of BlankForm.html:
SignedForm.html - this is identical to BlankForm.html but has placeholders in the document's signature line for my variables: +LearnerName+, +LearnerJob+ and +LearnerDate+
Print.html - this is identical to SignedForm.html (with the placeholders) but has added code to print on load: onload="window.print();"
My Build:
I built a 3-question quiz to capture name, job title and date (TextEntryName, TextEntryJob, and TextEntryDate) and created variables (varName, varJob and varDate) and triggers to receive the answers. The first slide has a web object on the top 80% of the slide to display BlankForm.html, which works great bcuz user can scroll up and down to read the form, and clarity is super clean. The lower 20% has input fields for name, job title and date.
When users answer the last question and press submit, results get pushed to LMS and the Results slide opens . Here I have web object - SignedForm.html - I want the form to have the variables embedded in the signature line. (I don't know WHERE/HOW to add the variables code to the SignedForm.html file.)
But MAINLY I need users to be able to print the "signed" form with the variables embedded in the signature line. I have a PRINT button on Results slide that jumps to a slide called - PrintExit.
PrintExit slide (looks identical to the Results slide) but this web object - Print.html - has the added code to print on load. Works great so far - user clicks PRINT button on Results slide, and Print.html pops right up to print. (Again... WHERE/HOW do I add the variables code in the Print.html file?)
Per other posts, I came up with the following but don't know where to add it in the html file and how to correctly code my placeholders:
<script>
var player=top.window.opener.GetPlayer();
var LearnerName=player.GetVar("varName");
var LearnerJob=player.GetVar("varJob");
var LearnerDate=player.GetVar("varDate");
document.write("<P><H2>Variable Name: " + LearnerName + "Variable Job: " + LearnerJob + "Variable Date: " + LearnerDate +"</P");
</script>
I'm exhausted and crawling to the finish line. Can anyone PLEASE assist? I added a 'redacted' copy of my Print.html file for your to view.
Many thanks!