--Hi Daniweb.
1st of all I apologize if I'm asking this Qn. in a wrong place,but as I came across this subject while I'm doying PhP code and so I thought I'd share it here as I hope someone may be came across the same scenario as I have.
The thing is this:
I want to print a Docement from the contents of a Div which I gave an id=Print_Document here below;
<div id="Print_Document">
<!-- My well formatted Docement Interface contents -->
</div>
And I have a button which triggers My javascript 'Print_Docement' function;<button onClick="Print_Doc('Print_Document')"><i class="printer"></i></button>
And the Javascript function for printing My document is at the top of My Div holding the Contents to be Printed.Here it is;
function Print_Doc(div)
{
var restorepage = document.body.innerHTML;
var printDiv = document.getElementById(div).innerHTML;
document.body.innerHTML = printDiv;
window.print();
document.body.innerHTML = restorepage;
}
</script>
Now all is well setup and I can print My Docement fine.
But One thing is for every printed Docement I have to Store its Id in a DB and so I though I'll just create a function to acomplish this task and call it within the Javascript code provided there above and so I did,But I came to realize that the Function to Store Docements Values in DB executes even if the Button to trigger Print_Doc(div) is not yet clicked.
One last thing is even if it is clicked I neede to know how to execute the Function to Store Values when the Ok button of the Print Dialog is Confirmed? Because Someone may go for Print Button and Cancel the Printing exercise right?
I tried lots of Google and I was so frustrated Even this didnt seem to help Me.Any help please?...