• Resolved efanwend

    (@efanwend)


    hey there,

    I have several sliders (total 5) in my form that each go from 0 to 100 to show percentage. All sliders together should form a result of 100%.

    Now, I want to create pre-set values for the sliders based on the choice of another drop-down field and the values of the choices there.

    Depending on the choice (total 4) in the drop-down, another calculated field shows the related value of the choice.

    my question, is there a way to create different pre-set values for the sliders, in form of a function in a hidden calc. field or another way?

    Can I create a function, so the sliders show e.g.
    slider 1: 20
    slider 2: 10
    slider 3: 10
    slider 4: 0
    slider 5: 60
    if the value of the drop-down choice is 15
    and
    slider 1: 20
    slider 2: 20
    slider 3: 20
    slider 4: 0
    slider 5: 40
    if the value of the drop-down choice is 10
    etc.

    Please let me know, if you need additional infos.
    Thanks!

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

    (@codepeople)

    Hello @efanwend

    Yes, of course. That’s possible.

    For example, assuming the slider fields are fieldname12, fieldname23, fieldname34, fieldname45, fieldname56 (the fields’ names are hypotheticals), and the dropdown field is the fieldname123

    You can implement the equation as follows:

    (function(){
        var f1=getField(12), 
            f2=getField(23), 
            f3=getField(34), 
            f4=getField(45), 
            f5=getField(56);
    
        if(fieldname123 == 15)
        {
            f1.setVal(20);
            f2.setVal(10);
            f3.setVal(10);
            f4.setVal(0);
            f5.setVal(60);
        }
        else if(fieldname123 == 10)
        {
            f1.setVal(20);
            f2.setVal(20);
            f3.setVal(20);
            f4.setVal(0);
            f5.setVal(40);
        }
    })()

    The getField operation receives the numeric part of the field’s name and returns its object representation. The setVal method assigns the value to the object.

    Best regards.

    Thread Starter efanwend

    (@efanwend)

    Thank you so much!

    It worked out perfectly.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Slider – variable predefined value based on drop-down choice value’ is closed to new replies.