I want to generate a clean print page with some information only. For this I am using the following code (well summarized) in javascript:
function myFunction() {
var myWindow = window.open(" ", "_self");
var str1 = "Janela de Impressão";
var result1 = str1.fontsize(5);
myWindow.document.write("<strong><center>", result1, "</center></strong>");
var str2 = "Dados da Impressão";
var result2 = str2.fontsize(5);
myWindow.document.write("<strong><br><br>", result2, "</strong>");
var salario_bruto = document.getElementById("salario").value;
myWindow.document.write("<strong><br>Salário: </strong>");
myWindow.document.write(salario_bruto);
}
<div>
Salário: <input id="salario" name="salario" type="text">
<button type="button" onclick="myFunction()">Imprimir</button>
</div>
I tested this offline and it worked perfectly. But when I went to the site I clicked on "print" and did not pass the amount of the salary. Any idea? Thanks.