Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 83
  • Last Modified:

Send to Print Preview database record with one click

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
romsom
Asked:
romsom
  • 2
1 Solution
 
Scott Fell, EE MVEDeveloperCommented:
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
 
romsomAuthor Commented:
Thank you very much, this is a solution worked for me.
0
 
romsomAuthor Commented:
Thank you very much!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now