Support Forum

Every time that you post a problem, PLEASE add the Joomla and the extension's versions and revisions (for example: Joomla 3.3.6, Contact Enhanced 3.3.5), PHP version and Server's Operating System. If you only manage only one site it is easier if you edit your profile and just add that information to your signature. Don't forget to add a detailed description of the problem. If possible, write down all steps to simulate the problem.

Before submitting a new post, PLEASE make sure you are running the latest version, test in different browsers (IE, FF, Chrome,..) and clear Joomla and browser's cache after every change you make.

Also, most questions are already answered in our FAQ and in iFAQ and Contact Enhanced documentation pages.

× Contact Enhanced is a contact component manager created to replace Joomla! core contacts component and add lots of advantages and new features (see Features ) and it offers many plugins and modules for several different purposes,
Product page | Documentation Page

Conditional fields not working since upgrade

1 year 2 months ago #26809 by gojyuan
Hi,
I am currently using Joomla 3.10.9 and getting ready to update to Joomla 4. I have been using Contact Enhanced since 2012.

In January I upgraded to PHP 8 and the secure captcha stopped working on my website. I upgraded Contact Enhanced PLUS 3.7.2 to Contact Enhanced PRO 3.12.1 ( probably did not need to change to PRO and I also changed my captcha plugin ).

I have always used conditional fields for my Gift Vouchers. Unfortunately they do not work since the upgrade. I am using a select list with conditional fields for the ‘Send Gift Voucher’

www.ryokangojyuan.com/gift-vouchers/purchase

Help greatly appreciated.
Regards
Linda

Please Log in or Create an account to join the conversation.

1 year 2 months ago #26812 by support
Dear Linda,

Thank you for subscribing again to Contact Enhanced.

You probably have this piece of code since Contact Enhanced for Joomla 2.5. It's still using MooTools instead of jQuery. Joomla no longer uses the MooTools javascript library and has been using jQuery or vanilla Javascript since Joomla 3.x. MooTools was included in Joomla 3.x for backward compatibility reasons, but I'm not sure why it is not loading for you.

Anyway, this way it's better because you don't need to load another library. I rewrote your Javascript code using jQuery. Please follow these steps:

1. Edit your Select Input "Send Gift voucher" and remove the onchange attribute where you've added the conditional javascript and save the Form Field.
2. Create a NEW Javascript Form Field with the code below and Save.
jQuery(function ($) {
  $('#ce-cf-container-71 select').on('change', function () {
    var value = $(this).val();
    const toRecipientFields = [41,164,42,43,45,46,47,48];
    const otherFields = [72,73,74,75,76,77];
 
    if (value == 'To Recipient') {
      $(toRecipientFields).each(function (i, el) {
        $('#ce-cf-container-' + el).css('display', 'block');
      });
      $(otherFields).each(function (i, el) {
        $('#ce-cf-container-' + el).css('display', 'none');
      });
    } else {
      $(toRecipientFields).each(function (i, el) {
        $('#ce-cf-container-' + el).css('display', 'none');
      });
      $(otherFields).each(function (i, el) {
        $('#ce-cf-container-' + el).css('display', 'block');
      });
    }
  });
});

3. Reload the form and it should now be working properly.

This code will require some adjustments when you upgrade to Joomla 4, but very few. Let me know when you upgrade and I'll do it for you.

Best regards,

Please Log in or Create an account to join the conversation.

1 year 2 months ago #26813 by gojyuan
Dear Douglas,

It worked perfectly, thank you.
I appreciate your wonderful support over the years.

Enjoy your day.
Regards
Linda

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum

Copyright © 2018 IdealExtensions.com. All Rights Reserved.

This site is not affiliated with or endorsed by the Joomla!™ Project. It is not supported or warranted by the Joomla!™ Project or Open Source Matters™. The Joomla!™ logo is used under a limited license granted by Open Source Matters™, the trademark holder in the United States and other countries.
We may collect your IP address and your browser's User Agent string while using our site for security reasons and deriving aggregate information (analytics). This information is retained for a minimum of 1 and a maximum of 24 months.
Feedback