skip to Main Content

I tried printing a particular div on a dynamic webpage which is a php file.

2

Answers


  1. you can use

    echo '<div></div>';
    
    Login or Signup to reply.
  2. to print a div you can use:

     <div id="print-div">
    ...content of div goes here...
    </div>
    

    add this function

    function printDiv() {
      var printDiv = document.getElementById("print-div");
      var printContent = printDiv.innerHTML;
      var printWindow = window.open("", "", "width=800,height=600");
      printWindow.document.write(printContent);
      printWindow.print();
      printWindow.close();
    }
    

    and try with this button

    <button onclick="printDiv()">Test Print Div</button>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search