I create simple form to show multiple row data to the table as described in tutorial. All works great. I want add print button like Joomla article to allow users send this table to printer.
Hi azz13,
Here's one way to add a print button to a a ChronoForms Thank You page.
In the Thank you page wrap the section that you want to print in div tags:
Add this button code to the page where you want the button to appear (probably outside the 'print_me' div).
Add Custom Code action to the On Submit event and add this code to it:
Save and test.
Notes: The code allows for you to add CSS styling by linking to a CSS file or adding some CSS directly to the css = \"\"; line.
If you prefer an image instead of a button use
Bob
Here's one way to add a print button to a a ChronoForms Thank You page.
In the Thank you page wrap the section that you want to print in div tags:
<div id='print_div'>
. . .
</div>
Add this button code to the page where you want the button to appear (probably outside the 'print_me' div).
<input type="button" value="Print" id='print_button' style='visibility: hidden;'></input>
Note that the button is invisible if the User doesn't have JavaScript enabled so that they don't see a print button that they can't use.Add Custom Code action to the On Submit event and add this code to it:
<?php
$doc =& JFactory::getDocument();
$script = "
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>'+$(id).innerHTML+'</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;
window.addEvent('domready', function() {
id = 'print_div';
$('print_button').setStyle('visibility', 'visible');
$('print_button').addEvent('click', printPage);
});
";
$doc->addScriptDeclaration($script);
?>
Save and test.
Notes: The code allows for you to add CSS styling by linking to a CSS file or adding some CSS directly to the css = \"\"; line.
If you prefer an image instead of a button use
<input type='image' src='media/system/images/printButton.png' id='print_button' />
Bob
Thanks for help. All working good.
There is one errror
<div id='print_me'> in Thank you page and id = 'print_div'; in Custom Code should be the same
There is one errror
<div id='print_me'> in Thank you page and id = 'print_div'; in Custom Code should be the same
first i'm so sorry for my question, bcuz maybe it sounds so stupid. i'm new in joomla.
So can u explain where can i find the "On Submit Event"??
i don't understand this sentence : 'Add Custom Code action to the On Submit event and add this code to it:'
So can u explain where can i find the "On Submit Event"??
i don't understand this sentence : 'Add Custom Code action to the On Submit event and add this code to it:'
Hi Admin,
I have just followed your instructions and made a print button on the "Thank Message" screen.
It is working very good when I enable the "Login" module.
But I don't want the "login" menu on my form, so I disable it.
After that the print button doesn't show up until I enable the "login" menu again.
Please you advise.
Regards,
Lily
I have just followed your instructions and made a print button on the "Thank Message" screen.
It is working very good when I enable the "Login" module.
But I don't want the "login" menu on my form, so I disable it.
After that the print button doesn't show up until I enable the "login" menu again.
Please you advise.
Regards,
Lily
Hi Lily,
There is no reason I can think of why the Login module would affect the print button. Please post a link to the form so I can take a quick look.
Bob
There is no reason I can think of why the Login module would affect the print button. Please post a link to the form so I can take a quick look.
Bob
Hi GH,
Thank you for you reply, but the form is built on a testing server which can't be accessed by outsider.
I finally know that if you use the template beez5, it will happen. Could you please look into that?
Thanks again
Regards,
Lily
Thank you for you reply, but the form is built on a testing server which can't be accessed by outsider.
I finally know that if you use the template beez5, it will happen. Could you please look into that?
Thanks again
Regards,
Lily
Hi Lily,
Please check and see if the MooTools library is being loaded on your page. I suspect that may be the difference.
Bob
Please check and see if the MooTools library is being loaded on your page. I suspect that may be the difference.
Bob
Hi Lily,
Look at the list of files in the page header when you view the page source. Or better, click F12 in your browser to access the web developer tools and look at the Sources tab.
Bob
Look at the list of files in the page header when you view the page source. Or better, click F12 in your browser to access the web developer tools and look at the Sources tab.
Bob
This topic is locked and no more replies can be posted.