Had anyone had any success populating an HTML table for printing using Javascript?
I have been using Javascript to provide learners with a document of their entries to bring to class.
I haven't populated a table before, and my HTML is very rusty. Where I'm struggling is knowing what requires a new line - I've prefixed each line with 'contents+='.
Can anyone with JS knowhow please take a look and let me know where I'm going wrong? Currently, it does nothing.
// Step 1. Connect JavaScript to the Storyline variables
var player = GetPlayer();
var RiseTitle=player.GetVar("varRiseTitle");
var QuestionText=player.GetVar("varQuestionText");
var TextEntry1=player.GetVar("TextEntry");
var TextEntry2=player.GetVar("TextEntry1");
var TextEntry3=player.GetVar("TextEntry2");
var TextEntry4=player.GetVar("TextEntry3");
var TextEntry5=player.GetVar("TextEntry4");
var TextEntry6=player.GetVar("TextEntry5");
var TextEntry7=player.GetVar("TextEntry6");
var TextEntry8=player.GetVar("TextEntry7");
var TextEntry9=player.GetVar("TextEntry8");
var TextEntry10=player.GetVar("TextEntry9");
var TextEntry11=player.GetVar("TextEntry10");
var TextEntry12=player.GetVar("TextEntry11");
// Step 2. The HTML Section - with the Storyline variables inserted
var contents = "<html><head></head><body style='width:650px;padding:20px;'>";
contents+="<div style='font-size:26px;font-weight:bold;margin-top:26px;margin-bottom:20px;'>"+RiseTitle+"</div>";
contents+="<div style='display:block;border-width:1px';><hr/></div>";
contents+="<div style='font-size:16px;font-weight:bold;'>"+QuestionText+"</div>";
contents+= "</body>"
contents+="<table>";
contents+="<thead>"
contents+="<tr>";
contents+="<th>"Core™ i5-9400F"</th>";
contents+="<th>"Celeron® N4020"</th>";
contents+="<th>"Ryzen™ 5 3600"</th>";
contents+="<th>"Athlon™ 3000G"</th>";
contents+="</tr>";
contents+="</thead>";
contents+="<tbody>";
contents+="<tr>";
contents+="<td>"+TextEntry1+"</td>";
contents+="<td>"+TextEntry2+"</td>";
contents+="<td>"+TextEntry3+"</td>";
contents+="<td>"+TextEntry4+"</td>";
contents+="</tr>";
contents+="</tbody>";
contents+="</table>";
contents+= "</html>";
// Step 3. Open the document window, write the HTML contents, and open the print window
var myWindow = window.open("","Print","width=810,height=610,scrollbars=1,resizable=1");
myWindow.document.write(contents);
myWindow.print();