I found this code to print in Javascript.
function printData()
{
var divToPrint=document.getElementById("printTable");
newWin= window.open("");
newWin.document.write(divToPrint.outerHTML);
newWin.print();
newWin.close();
}
The element ID "printTable" is the ID of the table that I want to print but unfortunately it only prints out the contents of the table and not the style of the table. I just want to have borders on it so that it is easier to read in print. Can anyone help me?
border="1"attribute, although this is an old & unstandardised way of applying borders with HTML4-5 (Afterall, it was just an simple example). You could either: inject a stylesheet to the head of the new window, or add inline styles to the table.