News:

AbanteCart v1.4.2 is released.

Main Menu

Do you like AbanteCart? Please rate AbanteCart or share your experience with other eCommerce entrepreneurs. Go to Softaculous rating page to add your rating or write a review

btn_switch style toggling

Started by hb007006, November 30, 2016, 02:43:03 AM

Previous topic - Next topic

hb007006

Hello,

How can I handle events in jquery or java script while toggling on btn_switch style?

For example when i click on ON i want alert ("hello ON") and when i click on Off I want to alert  ("hello OFF")


Thanks

hb007006


Basara

Hi.
Please post solution. This may help other users.  ;)

hb007006

define a switch button in your php like below

$this->data['form']['fields']['abc'] = $form->getFieldHtml(array(
            'type'    => 'checkbox',
            'name'    => 'abc',
            'value'   => 1,
            'checked' => false,
            'style'   => 'btn_switch'
      ));

Below is the jquery code
jQuery(function ($) {
     $("#frmName_abc_layer>button").on('click', function () {
          var abc_switcher = $("#frmName_abc");
     if(abc_switcher.val() == "0") {
             alert('Off');
          } else {
             alert('On');
          }
     });
});

Forum Rules Code of conduct
AbanteCart.com 2010 -