Random fields | WordPress.org

Hello @johnny7075

You can activate/deactivate random fields from the equations.

For example, assuming you have four fields, fieldname1, fieldname2, and fieldname3, and you want to activate one of them and disable the rest, after the user selects an option of radio buttons or checkbox field fieldname4.

The fields’ names are hypothetical, and used only to describe the process.

Insert a calculated field in the form and enter the following equations:

(function(){
var list = [fieldname1|n, fieldname2|n, fieldname3|n],
    index = FLOOR(RANDOM() * list.length);

if(fieldname4){
  for(var i in list) {
    if(i==index) ACTIVATEFIELD(list[i]);
    else IGNOREFIELD(list[i])
  }
}
})()

And that’s all.

Note I used some fields’ names with the |n modifier. The plugin replaces the fields’ names in the equations with their corresponding values, but the |n modifier tells the plugin you want to use the fields’ names and not their values.

Best regards.

Thanks for the super fast response!

 

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