• Resolved smopuim

    (@smopuim)


    Hello CodePeople! Your program is awesome! But it is interesting to know if it is possible to set a multiple dependency between the sliders. For example, there is a formula A=B/(C*D). You can easily calculate the value of A by moving the sliders B, C and D. But what to do so that the user can also change the slider A, and the values ​​of B, C, D change with a certain coefficient so that the formula is correct. Well, or at least one of the sliders B, C, D moved within the specified limits.

    for example https://youtu.be/aEcLVf86tSA

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

    (@codepeople)

    Hello @smopuim

    Thank you very much for using our plugin.

    I’ll try to describe the process with a hypothetical example.

    Suppose you have two sliding fields, fieldname1, and fieldname2, whose values range from 0 to 100, and you want to ensure that their sum is 100.

    Insert an “HTML Content” field in the form with the following piece of code:

    <script>
      jQuery(document).on('change', '[id*="fieldname1_"]', function(){
        var v = this.value;
        getField('fieldname2').setVal(100-v, true);
      });
      jQuery(document).on('change', '[id*="fieldname2_"]', function(){
        var v = this.value;
        getField('fieldname1').setVal(100-v, true);
      });
    </script>

    Best regards.

    Thread Starter smopuim

    (@smopuim)

    Thanks! Everything worked out! And how to get values ​​from other fields in order to correctly set the dependence of the slider movement. That is where var v = this.value; is defined; you need to set more (rather it is not correct, but for example) var d = getField(‘fieldname25’).val()

    Thread Starter smopuim

    (@smopuim)

    When I move the slider of field 1, the slider of field 2 moves, but this value is not taken into account in calculations in other fields until I move the slider of field 2.

    Plugin Author codepeople

    (@codepeople)

    Hello @smopuim

    You can trigger the evaluation of the equations after assigning the slider values. Continuing with the previous example:

    <script>
      jQuery(document).on('change', '[id*="fieldname1_"]', function(){
        var v = this.value;
        getField('fieldname2').setVal(100-v, true);
        EVALEQUATIONS(this.form);
      });
      jQuery(document).on('change', '[id*="fieldname2_"]', function(){
        var v = this.value;
        getField('fieldname1').setVal(100-v, true);
        EVALEQUATIONS(this.form);
      });
    </script>

    Best regards.

    Thread Starter smopuim

    (@smopuim)

    Everything worked out great! Also, I asked this above:

    How to get values ​​from other fields in order to correctly set the dependence of the slider movement. That is where var v = this.value; is defined; you need to set more (rather it is not correct, but for example) var d = getField(‘fieldname25’).val()

    Plugin Author codepeople

    (@codepeople)

    Hello @smopuim

    I’m not sure about your request. But if you are trying to get the value of a third-party field into the “HTML Content” code, your assumption is correct. You should use a code similar to:

    var d = getField('fieldname25').val();

    Best regards.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘multiple slider dependencies’ is closed to new replies.