PHP and Javascript - Automating one page printing function from another page

Asked

Viewed 816 times

1

My site has a query screen of registered events. For each one, I have the option of Edit Event that redirects me to a form:

    function editaEvento(val){
        var valor = val;
        location.href = "http://meusite.com.br/edicaoeventos?valor="+valor;
        // Função de edição pra abrir a página de formulário, semelhante ao do Index, mas que somente fará a edição
    }

Inside the editing form there is a button to print this form. I was looking to create a new function to Print the event from the consultation of registered events.

How can I do it? I thought of something like: repeat the editEvento function and adding a value of $_SESSION['imprime'] equal to 1. Then when the edit tab loads, it checks the value of Session. If it continues as 1, it activates form printing automatically.

I appreciate anyone who can help me.

1 answer

1

This is Hara. You can create on the Print button onclick="window.print()" And in CSS use the imagination of css with @media print I think that the case of Session is complicated because the verification is more complex, it tries to use print() itself and hide the fields that should not be shown in the print. Or else create an event.php press? idevento= and in this file configure the templates. Only it is more complicated. Ex: @page { size: A4; }

@media print {
    body{max-width: 100%}
    thead {display: table-header-group;}//bug do firefox
    #btnSave{display:none;}
    #btnCancel{display:none;}

}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.