I have a problem with printing a window, parts of window specifically. Site is Joomla. Javascript for printing:
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
<input type="button" onclick="printDiv('printableArea')" value="Print" />
Part I want to print is in this html block:
<div class="order-info-container" id="printableArea">
Everything gets generated properly except for Comment section in which comments are posted with Javascript again and this is the code block for generating them:
<?php if(count($this->comments)):
foreach ($this->comments as $key => $comment) { ?>
<div class="comment-container" id="comment">
<div class="comment-user-info-block">
<div class="comment-name"><h5><?php echo $comment->name; ?></h5></div>
<div class="comment-created"><?php echo date('Y-m-d', strtotime($comment->created)); ?></div>
</div>
<div class="comment-content"><?php echo $comment->comment; ?></div>
</div>
<?php }
endif;?>
They are in the big printable Area container so I'm really not sure why they aren't appearing on the print page. Everything else works fine.
For anyone interested, this is where I found print solution which works perfectly