Solved

Send to Print Preview database record with one click

Posted on 2016-09-28
3
48 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now