Guna

Guna

  • NA
  • 17
  • 0

Print Div Content Using JavaScript

Jan 14 2016 5:16 AM

Hai, 

I had used 4 DIV's in my web page.

During print a particular DIV, there is a need to print value of one Text Box (Note: before print user will type something in Text Box) and I had placed some Check Box also. The check box also need to be printed with check or unchecked whatever condition.

For this purpose, I had used the following code;

  1. <script type="text/javascript">  
  2.         function printDiv() {  
  3.             var divElements = document.getElementById("<%= Panel1.ClientID %>").innerHTML;  
  4.             var oldPage = document.body.innerHTML;  
  5.             document.body.innerHTML = "" + divElements + "";  
  6.             window.print();  
  7.             document.body.innerHTML = oldPage;  
  8.         }  
  9.     </script> 
 

The DIV is printing but without the value of Text Box.

Please help me to print the DIV with the value of Text Box and Check Boxes.

Thanks & Regards,

Guna


Answers (8)