Solved

Send to Print Preview database record with one click

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

759 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

19 Experts available now in Live!

Get 1:1 Help Now