• Resolved tilou

    (@tilou)


    Hi

    I would like to be able to insert a specific fieldname in the slider min and max input. Is there a way to do that.

    Thanks for this great plugin!!

    The page I need help with: [log in to see the link]

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

    (@codepeople)

    Hello @tilou,

    Actually, you can extend your form as you need or want.

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

    – Assuming the slider field is the fieldname123, the field for the min the fieldname456 and the field for the max the fieldname789

    You will need a calculated field as auxiliary (you can tick the checkbox in its settings for hiding it from the public form), with the following equation:

    
    (function(){
    var field = getField(123),
        value = field.val(),
        new_min = fieldname456,
        new_max = fieldname789;
    
        jQuery('[id*="'+field.name+'"].slider').slider('option', {'min': new_min, 'max': new_max});
        field.setVal( MAX(new_min,MIN(new_max,value)));
    })()
    

    and that’s all.
    Best regards.

    Thread Starter tilou

    (@tilou)

    Hi

    Thanks very much but
    actually, I wanted this:

    Slider min = fieldname1
    Slider max = fieldname2

    The slider min and max steps will be from fieldname1 to fieldname2. It is actually 0 to 100 steps.

    Thanks
    JL

    • This reply was modified 5 years, 10 months ago by tilou.
    Plugin Author codepeople

    (@codepeople)

    Hello @tilou

    As I said in the previous ticket, the current version of the plugin does not allow to include directly the names of other fields in these attributes and you need to emulate the relationship between the fields by programming.

    For example, in your form the fieldname44 is a slider, so, the code to use as the equation in the calculated field would be:

    
    
    (function(){
    var field = getField(44),
        value = field.val(),
        new_min = fieldname1,
        new_max = fieldname2;
    
        jQuery('[id*="'+field.name+'"].slider').slider('option', {'min': new_min, 'max': new_max});
        field.setVal( MAX(new_min,MIN(new_max,value)));
    })()
    

    Best regards.

    Thread Starter tilou

    (@tilou)

    Thanks a lot and what about jquery for Field Type: number? So that I can set max and min for a number field.

    • This reply was modified 5 years, 10 months ago by tilou.
    Plugin Author codepeople

    (@codepeople)

    Hello @tilou,

    I’ve published an update of the plugin that allows to enter other fields names in the attributes: min, max, and step of the slider controls.

    Now, concerning to the number fields the solution requires some of code, but it is simpler, for example, assuming the number field is the fieldname1, and you want to relate the min and max attributes to the fields: fieldname2 and fieldname3

    Insert a “HTML Content” field in the form and enter as its content the following piece of code:

    
    <script>
    jQuery(document).on('change', '[id*="fieldname2_"]', function(){jQuery('[id*="fieldname1_"]').attr('min', this.value);});
    jQuery(document).on('change', '[id*="fieldname3_"]', function(){jQuery('[id*="fieldname1_"]').attr('max', this.value);});
    </script>
    

    and that’s all.
    Best regards.

    Thread Starter tilou

    (@tilou)

    That’s perfect! You are the best! : )

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Use fieldname value in min and max in slider input’ is closed to new replies.