Send to printer?

  • 19 years ago

    Hello..


    I've a form.. upon submit a new page will be created with rearranged layout for printing purposes. How can I do it in such a way that, on submit button clicked:


    1) The new page will be redirected to but not on the screen (user can't see it);
    2) The new page will be send to the default printer straight for printing.


    Grateful for your advice please. Thank you.

  • 19 years ago

    Are you using something like ASP or PHP, or would it have to be just client-side javascript?


    You could have a frameset with two frames in, one taking up 100% and the other taking up 0%. When you click the submit button, it would redirect the 0% frame to a page with a series of things like this in:


    <script>document.write(parent.100-percent-frame-name.nameofaform.nameofacontrol.value);</script>


    ... then it'd load the new page and use information from the other page to make it up.


    You'd then do this inside the invisible page:


    <body onLoad ="document.print();">


    so that once it's loaded, it'll print the document.


    I'm presuming you have a basic knowledge of JavaScript, but if this doesn't quite work (i haven't tested it!!) feel free to email me and I'll make a fully working example and zip it and send it to you


    [email protected]


    good luck!

  • 19 years ago

     Thanks Paul.. But.. document.print() doesn't work.. Is there any other methods?? I've been search for tutorials on this on the internet.. but I'm kinna down in luck.. Grateful for your kind assistance please. Thank you.

  • 19 years ago

    sorry, i forgot the document object doesn't have a print() method! use the print() method of the window object instead, ie.


    <body onLoad ="javascript:window.print(self);">
    or
    <body onLoad ="javascript:window.print();">


    hope this works, if you can't get it quite to work, email me what you've done and i should be able to get it up and running! ([email protected])


    good luck :-)

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“C++ : Where friends have access to your private members.” - Gavin Russell Baker