Jquery - Open a new window with content from the current page
<p>I'm trying to create a 'print' button to open a new window and display a PHP Variable in it. </p>

<p>The code below is looped through the PHP script as many times as there are tickets, however I can't seem to get the correct number to display when the window opens (the number that displays in the print link is correct - but when the new window is opened it's incorrect). </p>

<pre><code>&lt;script type='text/javascript'&gt;
jQuery(function($) {
$('a.new-window').click(function(){

var recipe =  window.open('','PrintWindow','width=600,height=600');
var html = '&lt;html&gt;&lt;head&gt;&lt;title&gt;Print Your Ticket&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;div id="myprintticket"&gt;' + $('&lt;div /&gt;').append($('#ticket').clone()).html() + '&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;';
recipe.document.open();
recipe.document.write(html);
recipe.document.close();

return false;

});
});
&lt;/script&gt;

&lt;a href="" class="new-window"&gt;Print &lt;?php echo $EM_Booking-&gt;get_spaces() ?&gt;&lt;/a&gt; 

&lt;div style="display:none;"&gt;
&lt;div id="ticket"&gt;&lt;?php echo $EM_Booking-&gt;get_spaces() ?&gt;
&lt;/div&gt;

&lt;/div&gt;
</code></pre>
