Click here to Skip to main content
13,057,084 members (43,243 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Dear friends,

I am trying to print the divs content with the help of jquery.
But its not printing the latest changes done to the HTML elements its only printing the values and html elements those are initially returned by server side php via ajax and jason.

In other words I am dynamically populating the reservediv at first, then I apply other jquery script to update those dynamically created html elements values and I can see my results on screen, but when I call the print function to take a print its printing only the old values inititally returned by the server not the new values on the screen

I would appreciate the help.

Many thanks in advance.

the code is as follows.

<div id="reservediv" class="divmargin" style="display: none;">

<input type="submit" value="Update" id="reserveupdate" style="display: none;" />
<input type="button" value="Print" onclick="PrintElem('#reservediv')" class="btnprnt"  />
<input type="button" value="Save" class="btnprnt" id="savereserve"/>
<div id="resultsaving" > </div>
<div id="reserveaccountbtn"style="display: none;">
<input type="submit" value="RESERVE-XXXXXX8751"  class="bankmovementsbtn" id="btnreserve" style="display: none;">
<input type="text" value="" id="reserveaccounttext" class="bankmovementsbtn"style="display: none;">
<div id="openingbaldiv" class="divopening">
<input type ="button" value="Beginning   Balance" class="reconfields" id="openingbalbutton"/>
<input type="text" value="0" class="reconfields" id="openingbaltext" >
<div id="reconcilediv" class="divreconcile">
<input type ="button" value="Ending  Balance" class="reconfields" id="closingbalbutton"/>
<input type="text" value="" id="closingbaltext"  class="reconfields">
<div id="clearedbaldiv" class="divclearedbal">
<input type ="button" value="Cleared   Balance" class="reconfields" id="clearedbalbutton"/>
<input type="text" value="" id="clearedbaltext" class="reconfields" >
<div id="differencebaldiv" class="divdifferencebal">
<input type ="button" value="Difference" class="reconfields" id="differencebalbutton"/>
<input type="text" value="" id="differencebaltext"  class="reconfields">
<input type ="button" value="Check All" id ="selectchbx" class = "update" /> 
<input type ="button" value="Uncheck  All" id ="selectunchbx" class = "update" /> 
<input type ="button" value="Calculate" id ="reconcilereserve" class = "update" /> 

Code to make print via jquery

<script type="text/javascript">
    function PrintElem(elem)
    function Popup(data) 
        var mywindow ='','Print Area','height=900 width=950');
		mywindow.document.write('<input type="text" id="messageprint1" value=" For  Firefox browser Press ctr+p to Print then close the Popup window, For Google Chrome just Press ctr+p to print" />');
        mywindow.document.write('<html><head><link REL="STYLESHEET" TYPE="text/css"  HREF="printout.css" media="print"> <link REL="STYLESHEET" TYPE="text/css" HREF="generatereports.css" media="screen">  <title>Print Area</title>');
        /*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />');
        mywindow.document.write('</head><body >');
        return true;
Posted 17-Jan-13 15:14pm
Updated 17-Jan-13 15:26pm
Karthik. A41.2K

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This is working for me now


$('div input').each(function(){
$(this).bind("change keyup input",function(){


$('div input:checkbox').each(function(){
$(this).bind('click', function() {



This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170728.6 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100