Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author codepeople

    (@codepeople)

    Hi,

    In reality the feature you are requesting is easy to implement:

    Insert in the form a checkbox field, where one of choices will contain the text: toggle all, and the value: toggle-all

    Now insert a “HTML Content” field in the form with the following piece of code:

    <script>
    jQuery(document).on('click', '[value="toggle-all"]', function(){
    var me= jQuery(this);
    var checked = ( me.is(':checked') ) ? true : false;
    jQuery('[id="'+me.attr('id')+'"]').prop('checked', checked);
    });
    </script>

    and that’s all.

    If you need additional help with this feature that is not part of the plugin’s code, you should request a custom coding service, through my personal support page:

    https://cff.dwbooster.com/customization

    Best regards.

    Thread Starter tda325

    (@tda325)

    Thanks! Almost there… The code does toggle the checkboxes, but it does not trigger the dependent fields and graphics. Further thoughts? site is at https://www.SourceEO.com

    Plugin Author codepeople

    (@codepeople)

    Hi,

    You simply should modify the line of code:

    jQuery('[id="'+me.attr('id')+'"]').prop('checked', checked);

    as follows:

    jQuery('[id="'+me.attr('id')+'"]').prop('checked', checked).change();

    and that’s all.

    Thread Starter tda325

    (@tda325)

    sooooo close… It’s changing the math, but not carrying through to the custom code/ lightbox you wrote for me. Sorry to be such a problem. If you have a tipjar, I’ll be happy to contribute generously to the beer money for all the extra work. Just post or send me a link…

    Plugin Author codepeople

    (@codepeople)

    Hi,

    In this case the line of code should be:

    jQuery('[id="'+me.attr('id')+'"]').prop('checked', checked).change().click();

    Best regards.

    Thread Starter tda325

    (@tda325)

    that sorta works, but is painfully slow and triggers an “unresponsive script” error…

    Plugin Author codepeople

    (@codepeople)

    Hi,

    To prevent the javascript message, please, go to the settings page of the plugin through the menu option: “Settings/Calculated Fields Form”, untick the checkbox for managing the forms cache, and press the “Update” button.

    About the form’s execution time, I’ve not checked your form step by step, but a “toggle all” checkbox will evaluate all equations in the current form, and the equations in the second form if you have defined dependencies between both forms.

    The main form includes around 26 equations, but I guess that many of them may be reduced to only one, because are used only to create a global variable and return a value, so: Why not generate all global variables in a same equation, and assign the value to the other fields from this equation?

    For example, if you want assign a value to a field from an equation, you simply should assign a class to the field, for example: my-field, and as part of the equation, it is possible to use the piece of code:

    jQuery('.my-field input').val(3);

    The previous line of code assign the number 3 to the field identified by the class.

    Best regards.

    Thread Starter tda325

    (@tda325)

    If I understand you correctly, you’re saying I can combine, the 6-7 equations that are used to generate global variables into one. So if the first two are like so:

    (function(){
    totalstores = fieldname260;
    return totalstores;
    })()

    and

    (function(){
    avgsqft = fieldname7;
    return avgsqft;
    })()

    then would it look something like:
    (function(){
    totalstores = fieldname260;
    return totalstores;
    avgsqft = fieldname7;
    return avgsqft;
    })()
    .
    ?

    The page, btw, is split into two forms; the first one evaluates dynamically (and posts global variables) and the second one (which reads those global variables) has a “Calculate” button specifically to reduce the math load as well as allowing me to keep the top part visible all the time, while the rest is on a multi-page format.

    Plugin Author codepeople

    (@codepeople)

    Hi,

    Not really. I’m proposing reduce the number of calculated fields as possible replacing them by other type of fields, for example: number fields, in case the field be needed, because if the field is used only as auxiliary can be eliminated completely.

    For example, suppose there are two calculated fields:

    fieldname1 whose equation is:

    (function(){
    totalstores = fieldname260;
    return totalstores;
    })()

    and fielname2 whose equation is:

    (function(){
    avgsqft = fieldname7;
    return avgsqft;
    })()

    First, I replace the first calculated field by a number field, and assign to it an unique class name, for example: mynewfield

    and then, I modify the second equation as follows:

    (function(){
    totalstores = fieldname260;
    jQuery('.mynewfield input').val(totalstores);
    
    avgsqft = fieldname7;
    return avgsqft;
    })()

    I’ve replaced a calculated field by a number field (reducing the number of equations) and have assigned its value from the equation of the second calculated field. Applying the same logic for the rest of the equations, I’m sure the number of calculated fields and equations can be reduced dramatically, increasing your form performance.

    Best regards.

    Thread Starter tda325

    (@tda325)

    ok so if there was also a fieldname281 that had the value:
    (function(){
    baseenspend = fieldname1;
    return baseenspend;
    })()

    then fieldname2 would now be:
    .
    (function(){
    totalstores = fieldname260;
    jQuery(‘.mynewfield input’).val(totalstores);

    (function(){
    baseenspend = fieldname1;
    jQuery(‘.mynewfield input’).val(baseenspend);

    avgsqft = fieldname7;
    return avgsqft;
    })()

    plus I would delete fields 1 and 281, correct?

    Plugin Author codepeople

    (@codepeople)

    Hi,

    Not really, If you replace the fieldname281, by a number field with the class: mynewfield2 the equation would be:

    (function(){
    totalstores = fieldname260;
    jQuery('.mynewfield input').val(totalstores);
    
    baseenspend = fieldname1;
    jQuery('.mynewfield2 input').val(baseenspend);
    
    avgsqft = fieldname7;
    return avgsqft;
    })()

    The return instruction is only for the calculated field associated to the equation, the values of the other fields are assigned with jQuery, in reality the process is very simple, replace the calculated fields by another type of field, and assign their values from an unique equation associated to an unique calculated field.

    Best regards.

    Thread Starter tda325

    (@tda325)

    thanks! I had been editing my earlier response when you responded. I got closer, but still didn’t have it. I’ll take a stab at it now.

    Thread Starter tda325

    (@tda325)

    I replaced the value in fieldname286 with:
    function(){
    totalstores = fieldname260;
    jQuery(‘.mynewfield input’).val(totalstores);

    baseenspend = fieldname1;
    jQuery(‘.mynewfield2 input’).val(baseenspend);

    netpm = fieldname121;
    jQuery(‘.mynewfield3 input’).val(netpm);

    costperkwh = fieldname73;
    jQuery(‘.mynewfield4 input’).val(costperkwh);

    roihurdle = fieldname292;
    jQuery(‘.mynewfield5 input’).val(roihurdle);

    kwhsavedcons = fieldname75;
    jQuery(‘.mynewfield6 input’).val(kwhsavedcons);

    kwhsavedaggr = fieldname76;
    jQuery(‘.mynewfield7 input’).val(kwhsavedaggr);

    blicons = fieldname38;
    jQuery(‘.mynewfield8 input’).val(blicons);

    bliaggr = fieldname39;
    jQuery(‘.mynewfield9 input’).val(bliaggr);

    avgsqft = fieldname7;
    return avgsqft;
    })()

    The second form doesn’t seem to reading the global variables anymore…

    Plugin Author codepeople

    (@codepeople)

    Hi,

    You’ve forgotten the initial parenthesis, before the “function” word:

    (function(){
    totalstores = fieldname260;
    jQuery('.mynewfield input').val(totalstores);
    
    baseenspend = fieldname1;
    jQuery('.mynewfield2 input').val(baseenspend);
    
    netpm = fieldname121;
    jQuery('.mynewfield3 input').val(netpm);
    
    costperkwh = fieldname73;
    jQuery('.mynewfield4 input').val(costperkwh);
    
    roihurdle = fieldname292;
    jQuery('.mynewfield5 input').val(roihurdle);
    
    kwhsavedcons = fieldname75;
    jQuery('.mynewfield6 input').val(kwhsavedcons);
    
    kwhsavedaggr = fieldname76;
    jQuery('.mynewfield7 input').val(kwhsavedaggr);
    
    blicons = fieldname38;
    jQuery('.mynewfield8 input').val(blicons);
    
    bliaggr = fieldname39;
    jQuery('.mynewfield9 input').val(bliaggr);
    
    avgsqft = fieldname7;
    return avgsqft;
    })()

    Best regards.

    Thread Starter tda325

    (@tda325)

    Thanks so much. Apparently the monkey can be taught. Eventually…

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘"Toggle/Check All" in checkbox list’ is closed to new replies.