saving and printing the results of an asp script

ginag
ginag used Ask the Experts™
on
I have a dynamic asp form which generates results based on input from users and is displayed within an html table.  I want to be able to save and print this form along with other forms which contain instructions.  The instructions are stored separtely in a doc format and html.  What is the easiest way to print a package for this dynamically generated form.  To all the experts out there thanks in advance for your input.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2006
Commented:
You can print this page by simply having the body onload handler

<body onload="window.print()">

The instructions can be printed by opening those in another window. Again put onload even handler in the HTML page that you open. To open a new window use window.open("Instructions.html", "Instructions"); If you want to combine both calls in one function, you can do that by ...

<html>
<head>
<script language="javascript">
function BodyOnLoad()
{
    var oInstructionWindow = window.open("Instructions.html", "Instructions");
    oInstructionWindow.print();
    window.print();
}
</script>
</head>
<body onload="BodyOnLoad()">
</body>
</html>

Users won't like this behavior though.

Author

Commented:
Thanks very much for the input - one question though - I'm not completly clear as to what you're referring to when you say users won't like this behavior.  Are you referring to opening another window with the instructions or combining the calls in one function??  If so in your experience - what would be the best way to handle this as the users want to be able to print the whole package combined??
Top Expert 2006

Commented:
Yes. I was referring to opening another window just to print but if users don't want to click 2 links or navigate to 2 pages and then print, this might be the only alternative. You can try one more thing - to navigate the users automatically but for that you will need to put onbody handler in each page (even 'nstruction.htm). For example ...

MainPage.html

<body onload="window.print();location.href='Instruction.htm">

This is your report page.

</body>

Instruction.htm

<body onload="window.print();">

This is your instruction page.

</body>

Again in this case the user will get 2 print boxes but it won't open 2 windows.

Author

Commented:
Say, thanks you've been very helpful- that gives me a direction to go in.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial