I have the following code that outputs terms & conditions data (agb) for a specific vendor using php echo in a pop-up window. This works fine as long as there is only one vendor. When additional vendors are listed, the displayed data in the new window is the same as for the first vendor.
As far as I understand javascript is executed outside of the PHP and therefore the value of the string output is not updated (because ofmissing target?) and refers always to the first vendor, i.e. the JavaScript code will always fill the new window with the same content.
I think I need to pass a vendor ID or similar to the javascript function. But how can I achieve this?
PHP
<?php if ($_v->getId()): ?>
<p>Seller: <?php echo $_v->getVendorName() ?> </p>
<a href="" class="new-window">terms & conditions</a>
<div style="display:none;">
<div id="agb-text"><?php echo $_v->getData('agb')?></div>
</div>
JS:
<script type='text/javascript'>
jQuery(function($) {
$('a.new-window').click(function(){
var recipe = window.open('','PrintWindow','width=600,height=600');
var html = '<html><head><title>AGB</title></head><body><div id="my-id">' + $('<div />').append($('#agb-text').clone()).html() + '</div></body></html>';
recipe.document.open();
recipe.document.write(html);
recipe.document.close();
return false;
});
});
</script>