It is ok Kyle, one question
I will use CBradiofield for user option and HTMLcustomfield for visitor select options. Their connection will be established using
Code:
$(function () {
$('.selectEmailOptionsTypeInput').on('change', function () {
const select = $(this).closest('.selectEmailOptionsType').siblings('.selectEmailOptions');
if ($(this).val() === 'days') {
select.removeClass('hidden');
select.find('option.selectEmailOptionDays').removeClass('hidden').prop('disabled', false);
select.find('option.selectEmailOptionHours').addClass('hidden').prop('disabled', true);
} else if ($(this).val() === 'hours') {
select.removeClass('hidden');
select.find('option.selectEmailOptionHours').removeClass('hidden').prop('disabled', false);
select.find('option.selectEmailOptionDays').addClass('hidden').prop('disabled', true);
} else if ($(this).val() === 'noemail') {
select.addClass('hidden');
}
}).trigger('change');
});
Do you think it will be wise to use something like the below in order to add the classes missing from the normal CBradiofield in order to make it work?
Code:
$('#cbfr_336').addClass('selectEmailOptionsType');
$('#cb_emailoptions_type_cbf0').addClass('selectEmailOptionsTypeInput');
$('#cb_emailoptions_type_cbf1').addClass('selectEmailOptionsTypeInput');
$('#cb_emailoptions_type_cbf2').addClass('selectEmailOptionsTypeInput');
Edit1: I have managed to use conditional on "noemail" value and the custom HTMLselectfield (emailoptions) becomes hidden based on the selection of the normal CBradiofield (emailoptions_type).
I haven't managed so far to make JQueryAutoAction to work. I have tried calling the ids instead of classes with no luck
Code:
$( '#cb_emailoptions_type_cbf0, #cb_emailoptions_type_cbf1, #cb_emailoptions_type_cbf2').on('change', function () {
const select = $( this ).closest( '#cbfv_336' ).siblings( '.selectEmailOptions' );
I have also tried to add classes to CBradiofieldoptions like
Code:
var div = $('#cbfr_336');
var cbf0 = $('#cb_emailoptions_type_cbf0');
var cbf1 = $('#cb_emailoptions_type_cbf1');
var cbf2 = $('#cb_emailoptions_type_cbf2');
div.className += " selectEmailOptionsType";
cbf0.className += " selectEmailOptionsTypeInput";
cbf1.className += " selectEmailOptionsTypeInput";
cbf2.className += " selectEmailOptionsTypeInput";
or
Code:
$('[name="cb_emailoptions_type"]').click(function () {
$('#cbfv_336').addClass('selectEmailOptionsType');
$('#cb_emailoptions_type_cbf0').addClass('selectEmailOptionsTypeInput');
$('#cb_emailoptions_type_cbf1').addClass('selectEmailOptionsTypeInput');
$('#cb_emailoptions_type_cbf2').addClass('selectEmailOptionsTypeInput');
});
Any help would be appreciated...