Solved

Send to Print Preview database record with one click

Posted on 2016-09-28
3
61 Views
Last Modified: 2016-09-29
I have a web page which displays a database record, but it also has images, tables, etc. that I don't want to print.
This page has a Print icon. When it's clicked it takes the user to a page where only a logo and the database record is displayed:

<div align="right"><img src="/images/Logo.jpg"></div>
<%=rs("Message") %>

I would like to avoid this extra click. Is it possible to send the above info (logo + record) to the Print Manager (Preview) without first displaying the printer friendly page?
0
Comment
Question by:romsom
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 41821035
Yes you can do this without using a "print" only.  The key is using media queries for print or screen.  https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries

Notice my code below using the classes screenonly and printonly inside the appropriate media queries.  Run the code and just File>Print from your browser and note what happens.

http://jsbin.com/redubifiso/edit?html,output
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <style>
    @media screen {
    .printonly {
       display:none;
    }
}
        @media print {
    .screenonly {
       display:none;
    }
}
  </style>
</head>
<body>
  <div class="screenonly">I show up only on the screen</div>
  <div>I show up on screen and print <span class="screenonly">I only show on screen</span></div>
    <div class="printonly">I only show up in print</div>
</body>
</html>

Open in new window

0
 

Author Comment

by:romsom
ID: 41821883
Thank you very much, this is a solution worked for me.
0
 

Author Closing Comment

by:romsom
ID: 41821885
Thank you very much!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question