Set value depending on dropdown selection

[ad_1]

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.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer