Hi Guys
I'm trying to use the tutorial on how to print a form, by including some code and a button.
My form gives me a result page that I output via PHP in a customcode module.
The top of the custom code looks like this:
This shows the button, but it doesn't react.
As you can see this is copied directly from the tutorial.
I was wondering if I should just 'echo' the $script into the page (with <script> tags around it) instead of the doc->addScriptDeclaration?
I tried doing this, but I didn't see any change...
I'm trying to use the tutorial on how to print a form, by including some code and a button.
My form gives me a result page that I output via PHP in a customcode module.
The top of the custom code looks like this:
<?php
$doc = JFactory::getDocument();
$script = "
jQuery(document).ready(function(jQ){
function printPage()
{
var html, css, csss_file, printWin;
css = \"\";
css = \"<style type='text/css'>\"+css+\"</style>\";
css_url = '';
if ( css_url !== '' ) {
css_url = \"<link rel='stylesheet' type='text/css' href='\"+css_url+\"' media='print' />\";
}
html = '<html><head>'+css+css_url+'</head>'+jQ(id).html()+'</html>';
printWin = window.open('', '', 'left=100, top=100, width=600, height=400, toolbar=0, scrollbars=0, status=0' );
printWin.document.write(html);
printWin.document.close();
printWin.focus();
printWin.print();
printWin.close();
}
var id;
id = '#print_div';
jQ('#print_button').css('visibility', 'visible');
jQ('#print_button').click(printPage);
});
";
$doc->addScriptDeclaration($script);
echo '<div id="print_div" ><table><tr><td colspan="9"><h2>Turberegning</h2></td><td align="right">
<input type="image" src="/media/system/images/printButton.png" id="print_button" />
</td></tr>
...
This shows the button, but it doesn't react.
As you can see this is copied directly from the tutorial.
I was wondering if I should just 'echo' the $script into the page (with <script> tags around it) instead of the doc->addScriptDeclaration?
I tried doing this, but I didn't see any change...