mardi 22 décembre 2015

I want to print div content and pass that value when checkbox is clicked

I am new to php and javascript, I want to print the dynamic <div> content when checkbox is checked and then print those values print button is clicked. With this script I can only print when one checkbox is checked. I want to print when multiple checkbox are selected.

Thanks in advance.

<?php
$action_string = html_entity_decode($OrderItemWorkflow['OrderItemWorkflow']['action_string']); 

<div id="div1" style=display:none;>
<?php  echo str_replace('|', "<br>", $action_string); ?>
</div>

<input type="checkbox" id="chk1" value="div1" onClick="show(this);" /> <b class="account">Test Checkbox</b>      

<script>
function show(chk)
    {
        document.getElementById("div1").style.display = chk.checked ? "block" : "none";
        var divToPrint = document.getElementById('div1');
        var popupWin = window.open('', '_blank');
        popupWin.document.open();
        popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
        popupWin.document.close();    
    }
</script>




Aucun commentaire:

Enregistrer un commentaire