var printContents = document.getElementById('IDFORTHEPRINTDIV').innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
var mywindow = window.open('', 'my div', 'height=400,width=600');
mywindow.document.write('<html><head><title></title>');
/*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />');
mywindow.document.write('</head><body >');
mywindow.document.write(printContents);
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10
mywindow.print();
mywindow.close();
document.body.innerHTML = originalContents;
similarly keep on adding the contents to the mainwindow.Write and it will print.
Thanks
KASANI007, if this helps please login to Mark As Answer. | Alert Moderator