Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Nov 2002
    Location
    Texas
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Printing multiple pages -- does it require server side?

    Hello,

    I'm trying to come up with a print button that allows the user to print a series of pages (a "print all" button).

    I can easily write a Javascript that prints the window the user is currently in, but am not sure how to modify it to print other pages the user is not in. Can Javascript do something like this, or is this something only server side scripting can do?



    Thanks for your insight,

    Steve

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Javascript can do that by loading each page into an IFRAME and then printing it but that would cause the user to get prompted once for each web page to be printed. You could also run a series of IMFRAMES to load all the pages into a single combo page and print it and only end up prompting the user once.

  • #3
    New Coder
    Join Date
    Nov 2002
    Location
    Texas
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how about for Netscape 4?

    Ok, that works for recent browser versions. Thanks! But unfortunately I have to make it work for Netscape 4 as well, and I understand Netscape 4 doesn't recognize IFRAME.

    Anybody have any thoughts on this?

  • #4
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    could you have just plain frames that were all printed at the same time? but this might still require prompts for each time.

    Another Idea might be to have an array that equals the sources for each page. And depending on wich combo pages to print, the sources could be added and made into one thing to do a write() with. and then printed such as:
    function combp() {
    var x = new Array(4)
    x[0] = "hi how are you"
    x[1] = "whats up"
    x[2] = "be happy (:"
    var sr = "<html><script>document.print()</script><body>"
    for (var i = 0; i < x.length; i++) {
    if (elements[i].checked) {
    sr = sr + x[i]
    }
    }
    sr = sr + "</body></html>
    document.write(sr)
    }
    <body>
    1<input type="checkbox">
    2<input type="checkbox">
    3<input type="checkbox">
    4<input type="checkbox">
    <input type="button" value="print selected" onClick="combp()">

    This script might have errors in it ( not sure about elements[i].checked) but I just made it as an example, the sr value would be what ever you needed the script tag or meta tag to be, for the printing, and the values of x would be the source inside the body tag of each page
    Kris Hubby
    kwhubby site

  • #5
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    <html>
    This one actualy works (at least in IE, not sure if getElementById works in netcape):

    <script>
    function combp() {
    var x = new Array(3)
    x[0] = "hi how are you <a href='http://google.com'>google</a> "
    x[1] = "whats up "
    x[2] = "be happy and google (: <img src ='http://www.google.com/images/logo.gif'>"
    var asdf = "<html><body onload='javascript: window.print();'>"
    for (var i = 0; i < x.length; i++) {
    if (document.getElementById("m" + i).checked) {
    asdf = asdf + x[i]
    }
    }
    asdf = asdf + "</body></html>"
    document.write(asdf)
    document.close()
    }
    </script>
    <body>
    1<input type="checkbox" name ="m0">
    2<input type="checkbox" name ="m1">
    3<input type="checkbox" name ="m2">
    <input type="button" value="print selected" onClick="combp()">
    </html>

    edit:
    hmm. thats really wierd, the onload='java script actualy is onload='javascript
    but the forum is making it have a space??!!!
    Last edited by kwhubby; 11-16-2002 at 08:12 AM.
    Kris Hubby
    kwhubby site

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: how about for Netscape 4?

    Originally posted by smanning
    Ok, that works for recent browser versions. Thanks! But unfortunately I have to make it work for Netscape 4 as well, and I understand Netscape 4 doesn't recognize IFRAME.

    Anybody have any thoughts on this?
    Netscape 4 has a near enough equivalent to IFRAME called ILAYER that you should be able to use for the Luddites in your organization.

  • #7
    New to the CF scene
    Join Date
    Mar 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by smanning
    I'm trying to come up with a print button that allows the user to print a series of pages (a "print all" button).
    I'm trying to do this too but so far have had no luck...

    Quote Originally Posted by kwhubby
    <html>
    This one actualy works (at least in IE, not sure if getElementById works in netcape):

    <script>
    function combp() {
    var x = new Array(3)
    x[0] = "hi how are you <a href='http://google.com'>google</a> "
    x[1] = "whats up "
    x[2] = "be happy and google (: <img src ='http://www.google.com/images/logo.gif'>"
    var asdf = "<html><body onload='javascript: window.print();'>"
    for (var i = 0; i < x.length; i++) {
    if (document.getElementById("m" + i).checked) {
    asdf = asdf + x[i]
    }
    }
    asdf = asdf + "</body></html>"
    document.write(asdf)
    document.close()
    }
    </script>
    <body>
    1<input type="checkbox" name ="m0">
    2<input type="checkbox" name ="m1">
    3<input type="checkbox" name ="m2">
    <input type="button" value="print selected" onClick="combp()">
    </html>
    This is the closest thing I've seen to what I'm actually after. Nice work! The main problem with this code is that you have to have the X array hardwired by the looks of it.

    Is it possible to replace the content of each array record with code from different HTML pages like in my dodgy example below?

    Code:
    x[0] = "===I want the content from mypage1.htm to go in here===" 
    x[1] = "===I want the content from mypage2.htm to go in here===" 
    x[2] = "===I want the content from mypage3.htm to go in here==="
    Any help is very much appreciated! Thanks!
    Chris

  • #8
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    5 years have passed and I still trying to solve this problem!!!

  • #9
    New Coder
    Join Date
    Sep 2011
    Posts
    43
    Thanks
    6
    Thanked 6 Times in 6 Posts
    5 years have passed and I still trying to solve this problem!!!
    You're kidding, right?

    If not, root through some of this stuff and see if it gives you any ideas on something you can cobble together.

    http://graciesdad.wordpress.com/2007...tiple-iframes/
    printing multiple separate web pages
    http://www.codeproject.com/Answers/5...A.aspx#answer1
    http://dryicons.com/blog/2008/04/26/...r-application/
    http://tycoontalk.freelancer.com/jav...avascript.html
    http://windows.podnova.com/software/178768.htm
    http://justtalkaboutweb.com/2008/05/...e-and-firefox/
    http://www.menace.co.nz/egovt/13.1.html
    http://www.techtricky.com/print-part...ge-javascript/
    http://www.codestore.net/store.nsf/unid/DOMM-4WMEU6

    You know, one way would be to populate just one iframe (or layered div) with a concatenated set of pages (which php could handle) and then print that out.

    You could have php insert page breaks as desired before sending the pages to the iframe - one click would send it to the printer - keep it simple, one ajax call with the parameters set to the desired pages would do the trick. I'd recommend one shared css for the bunch, the browser might choke on any more than that (and they have, if you read through the experiences cited in some of the links above).

    .
    .
    Last edited by morongo47; 09-24-2011 at 06:30 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •