Solved

Send to Print Preview database record with one click

Posted on 2016-09-28
3
67 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 53

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

Industry Leaders: 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

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 …
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
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…

734 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