Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Print page after updating data

Posted on 2006-11-08
12
Medium Priority
?
204 Views
Last Modified: 2010-04-06
I have a record page bound to a mySQL table. It has a save button on it.
I want to be able to change the button to a "save and print" button and print the page without the graphics and tbe buttons. I thought I would construct another page without the graphics and buttons and print that but the problem is updating the data on the second page.
Is there any way of calling up the second page and passing it the id of the record just saved on the first one and then printing it, this all being done without the user seeing the process?

Regards
Brian
0
Comment
Question by:bogorman
[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
  • 5
  • 4
  • 3
12 Comments
 
LVL 8

Expert Comment

by:radnor
ID: 17900609
I have for a client of mine, 2 css files.  One used for display and the other printing.  

<link href="xxxx.css" rel="stylesheet" type="text/css" media="screen" />
<link href="xxxxp.css" rel="stylesheet" type="text/css" media="print" />

Items I do NOT wanted printed have this:

#leftcontent {
      display:none;
}

On this site, leftcontent describes my nav menu.  So when the page is printed, the menu is NOT included.

Hope this helps.
0
 
LVL 8

Expert Comment

by:radnor
ID: 17900639
Not sure if you can include on the last line of your script this:
window.print();  to print the page when done.
0
 

Author Comment

by:bogorman
ID: 17900938
hi radnor,
Thanks very much. I am quite new to CSS/Web Design.
I assume that the first stylesheet would only be applied to the page when it is displayed, the second only when the page is printed.
The two areas of my page which I do not want to be printed are the section with the class Header (which has the graphic heading) and the bottom area which has class Bottom)
So if I give each an id="noprint" and put in the "printing" stylesheet

#noprint{
display:none
}

together with all the other styles from my "display" stylesheet, it should work. Have not tried it yet - just wanted to make sure I've got it right!
Regards
Brian

0
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!

 

Author Comment

by:bogorman
ID: 17900951
Hi radnor,
Just another point. I suppose that the two stylesheets can be identical apart from the addition of the noprint style to the printing one?
Regards
Brian
0
 
LVL 8

Assisted Solution

by:radnor
radnor earned 1000 total points
ID: 17901163
Well, you do not want your header printed  In your CSS for PRINT

.Header{
     display:none
}

Have fun with it!
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 17904856
And radnor's suggestion of window.print you can do with
<body onLoad="window.print()">
0
 

Author Comment

by:bogorman
ID: 17905382
Hi,
Yes, I see. I suppose I could have the record page with a save and print button which saves the record and then opens a "print" page with no graphics on it, passing the record id to it as a parameter. This would print automatically, but how can I close the page automatically and return to the original one?
Regards
Brian
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 17905487
You cannot reliably print and close. wmv can open a new window, print it and have a close link or button
0
 

Author Comment

by:bogorman
ID: 17905513
Hi,
I suppose, then, it might be best to adopt radnor's idea with the two stylesheets, one for display and one for printing and keep to one page.
The only problem then would be "converting" listboxes to textboxes for printing, otherwise they would look wrong.
Perhaps I could have two controls to hold the data when I use a listbox, one the listbox and the other a  textbox with an id which hides it in display mode. If I do this and use the ifchange event to copy the data over from the listbox to the textbox, would it accept the data if its id hides it in display mode?
Regards
Brian
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 17905759
yes.
<input name="printfield1" class="print" value="">
<select onChange="this.form.printfield1.value=this.options[this.selectedIndex].value" class="noPrint">
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 1000 total points
ID: 17905886
Or better, since some browser do not print the contents of form fields:

<span id="showSelect1" class="print"></span>
<select onChange="document.getElementById('showSelect1').innerHTML='$'+this.options[this.selectedIndex].value" class="noPrint">


0
 

Author Comment

by:bogorman
ID: 17907213
Hi radnor and mplungjan,
Thanks VERY MUCH for your excellent advice. You have both helped me so much and I have solved the problem with your advice.
Will split the points.
Regards
Brian
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

722 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