Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: HTML PHP jQuery
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>
<div id="reconcilediv" class="divreconcile">
<input type ="button" value="Ending  Balance" class="reconfields" id="closingbalbutton"/>
<input type="text" value="" id="closingbaltext"  class="reconfields">
</div>
 
<div id="clearedbaldiv" class="divclearedbal">
<input type ="button" value="Cleared   Balance" class="reconfields" id="clearedbalbutton"/>
<input type="text" value="" id="clearedbaltext" class="reconfields" >
</div>
 
<div id="differencebaldiv" class="divdifferencebal">
<input type ="button" value="Difference" class="reconfields" id="differencebalbutton"/>
<input type="text" value="" id="differencebaltext"  class="reconfields">
</div>
 
<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)
    {
        Popup($(elem).html());
    }
 
    function Popup(data) 
    {
        var mywindow = window.open('','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 >');
        mywindow.document.write(data);
        mywindow.document.write('</body></html>');
 
        //mywindow.print();
        //mywindow.close();

        return true;
    } 
	
	</script>
 
Posted 17-Jan-13 15:14pm
Edited 17-Jan-13 15:26pm
v2

1 solution

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

Solution 1

This is working for me now
 

 
$(document).ready(function(){
 
$('div input').each(function(){
$(this).bind("change keyup input",function(){
$(this).attr('value',$(this).val());
});


});
 

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

});
 

 
});
  Permalink  

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

  Print Answers RSS
0 CPallini 375
1 Sergey Alexandrovich Kryukov 370
2 BillWoodruff 314
3 George Jonsson 274
4 OriginalGriff 257
0 OriginalGriff 5,030
1 CPallini 4,115
2 Sergey Alexandrovich Kryukov 3,554
3 George Jonsson 2,826
4 Gihan Liyanage 2,386


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2014
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