• Resolved michaelrieder

    (@michaelrieder)


    Hi CodePeople

    I do not want to stress you to much, but I didn’t find a solution in the doc.

    How can I set the value of a slider field (e.g. getField(25).setVal(200);) depending on a dropdown selection.

    Best Regards Michael

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

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

    (@codepeople)

    Hello @michaelrieder

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

    Assuming you have the number field fieldname1 and the slider field fieldname2, and you want to set the slider value by coding as follows:

    If the fieldname1 value is less than or equal to 25, set the slider value to 25.
    If the fieldname1 value is greater than 25 and less than or equal to 50, set the slider value to 50. Otherwise, set the value 100.

    In this hypothetical case, you can insert a calculated field in the form to be used as an auxiliary and enter the equation:

    
    (function(){
    let value;
    if(fieldname1<=25) value = 25;
    else if(fieldname1<=50) value = 50;
    else value = 100;
    
    getField(fieldname2|n).setVal(value);
    })()

    Best regards.

    Thread Starter michaelrieder

    (@michaelrieder)

    Hi CodePeople

    Ok, the example works. I would like to set the condition to the default choice of the dropdown field. like: if(fieldname1==default). If this is not possible then I have to use if(fieldname1|v==’xxx’). Here I have a html problem because within xxx I have two special characters like ‘ (apos).

    Plugin Author codepeople

    (@codepeople)

    Hello @michaelrieder,

    If the default value of the Dropdown field is the text ‘default’, you must enclose it between single-quotes or double-quotes symbols. Like:

    
    (function(){
    let value;
    if(fieldname1 == 'default') value = 25;
    else value = 100;
    
    getField(fieldname2|n).setVal(value);
    })()

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Set value depending on dropdown selection’ is closed to new replies.