简体   繁体   中英

how to add onclick event in joomla button

if($this->params->get('show_cart_proceed',1)) {
  echo $this->cart->displayButton(JText::_(''),'checkout',$this->params,hikashop_completeLink('checkout'.$url_itemid),'');
}

I have this code for a checkout button in my site. How to add the onclick event in this?

Blocks of JavaScript code can be declared directly within a component or module's display template using the JDocument

<?php
$document = JFactory::getDocument();
$document->addScriptDeclaration('
    window.event("domready", function() {
        document.getElementById('buttonId').onclick = function () {};
    });
');
?>

or if you have external javascript then you can function there and import the script if you have not imported using

<?php
$document = JFactory::getDocument();
$document->addScript('/media/system/js/sample.js');
?>

Refer document

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM