I have a page Print page where users can print cryptograms.

There are a lot of controls on the page which I really don't want to show up when the page is printed but are necessary to format the page prior to printing.

There is a simple solution using jQuery:

I wrap the controls in divs with id's of bottombuttons and pb and then add a handler for clicking the print button.

Here is the handler for the Print Button:

view plain print about
1$("#button5").click(function() {
2        toggleButtons("No");
3        window.print();
4        toggleButtons("Yes");
5        return false;
6    })
and here is the function toggleButtons:
view plain print about
1function toggleButtons(on){
2    if(on=="Yes"){
3        $("#botombuttons").show();
4        $("#pb").show();
5    }
6    else{
7            $("#botombuttons").hide();
8            $("#pb").hide();
9    }
10    return true;
11}

The result is that the controls disappear, then the window is printed and the controls restored.