Forum Discussion
If you just read the threads, I posted a solution ages ago. But here it is again especially for you:
The javascript is as follows: (please note the 2nd and 3rd line- i.e. text1 and variable1- these must be changed accordingly. Good luck.
var player = GetPlayer();
var modelAnswer = player.GetVar("text1");
var yourAnswer = player.GetVar("variable1");
var mywindow = window.open('', 'Printing', 'height=400,width=600');
mywindow.document.write('<html><head><title>Printing</title>');
mywindow.document.write('</head><body >');
mywindow.document.write('<h2>Here is the Model Answer</h2>');
mywindow.document.write(modelAnswer);
mywindow.document.write('<h2>Here is Your Answer</h2>');
mywindow.document.write(yourAnswer);
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10
mywindow.print();
mywindow.close();
Hi Sam
Thanks for sharing your javascript in this forum. I have been successful in replicating your file with the script.
Now I am trying to have 3 variables (text input fields) appear in a table (1 row, 3 columns). I have the html to create the table but don't know how/where to include the variables. I have included the variable names in between <td> and </td> tags as placeholders.
Here is the what I have so far:
var player = GetPlayer();
var well = player.GetVar("W1");
var better = player.GetVar("B1");
var how = player.GetVar("H1");
var mywindow = window.open('', 'Printing', 'height=400,width=600');
mywindow.document.write('<html><head><title>Activity 1</title>');
mywindow.document.write('</head><body >');
mywindow.document.write('<h1>Activity 1</h1>');
mywindow.document.write('<h2>Purpose</h2>');
mywindow.document.write('<p>The purpose of this exercise is to</p>');
mywindow.document.write('<table style="width:100%">');
mywindow.document.write('<tr>');
mywindow.document.write('<th>What I did well</th>');
mywindow.document.write('<th>What I can improve on</th> ');
mywindow.document.write('<th>How I am going to improve</th>');
mywindow.document.write('</tr>')
mywindow.document.write('<tr>');
mywindow.document.write('<td>var well</td>'); //var well is placeholder
mywindow.document.write('<td>var better</td>'); //var better is placeholder
mywindow.document.write('<td>var how</td>'); //var how is placeholder
mywindow.document.write('</tr>');
mywindow.document.write('</table>');
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10
mywindow.print();
mywindow.close();
I will attach the SL file.