I have a table in a PHP page. It is a invoice. So I want to print it after adding items to it, and I had already done the coding part and all the things are working properly.
Now I just want to print that invoice table to a paper by pressing a button. I searched on Google but no clue is found to do that.
Can any one help me?
This is my table on right hand side. It is populated by the form in left hand side so I just want to print that right hand side table:
And add script:
This script will initially show print preview of the content that is inside your table.
$[document].ready[function[]{
$['#printPage'].click[function[]{
var data = '';
data += '';
data += $['#your_content'].html[];
data += '';
myWindow=window.open['','','width=200,height=100'];
myWindow.innerWidth = screen.width;
myWindow.innerHeight = screen.height;
myWindow.screenX = 0;
myWindow.screenY = 0;
myWindow.document.write[data];
myWindow.focus[];
}];
}];
Copy the script part and put it on the top of your page. And put the print link, [above anchor tag] wherever you want. And make sure you have included the jquery script file.
answered Jul 22, 2012 at 4:57
Print function printPage[]{ var tableData = '
You can see the demo here: //jsfiddle.net/Pxqtb/
answered Jul 22, 2012 at 6:11
pat34515pat34515
1,93912 silver badges13 bronze badges
0
i used this code and it solved my problem. thank you all for helping me.....
function printlayout[] {
var data = '';
var DocumentContainer = document.getElementById['printlayout'];
//data += $['printlayoutable'].html[];
//data += '