• Resolved johnny7075

    (@johnny7075)


    Hi there,
    Is it possible to display random fields with the radio buttons?
    I can designate which fields to show when a button is selected but not a random field or series of random fields.
    Thanks!

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

    (@codepeople)

    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.

    Thread Starter johnny7075

    (@johnny7075)

    Thanks for the super fast response!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Random fields’ is closed to new replies.