0

I would like to hide/show my "Custom Profile Group" based on the value of "Price Set Total". I already have an extension with this Jquery, but seems to be not working. Any help would be appreciated. Thanks in advance.

  CRM_Core_Resources::singleton()->addScript("
     CRM.$(function($) {
        hideshowMainProfile();
    $('#priceset [price]').bind('keyup',hideshowMainProfile);

    function hideshowMainProfile() {
        let priceValue = $('#priceset [price]').val();
    if (priceValue.length > 1) {
      $('.crm-public-form-item.crm-group.custom_pre_profile-group').show();
    }
    else {
      $('.crm-public-form-item.crm-group.custom_pre_profile-group').hide();
    }
  }
    });
");
2

I would use calculateTotalFee() to check if total amount is > 0.

CRM_Core_Resources::singleton()->addScript("
  CRM.$(function($) {
    hideshowMainProfile();
    $('#priceset [price]').bind('change keyup click blur', hideshowMainProfile);

    function hideshowMainProfile() {
      if (calculateTotalFee() > 0) {
        $('.crm-public-form-item.crm-group.custom_pre_profile-group').show();
      }
      else {
        $('.crm-public-form-item.crm-group.custom_pre_profile-group').hide();
      }
    }
  });
");
| improve this answer | |
  • Perfect! Thanks – Tapash May 7 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.