Support » Plugin: Calculated Fields Form » If the checkbox is activated, then change the value in field XYZ

  • Resolved SamuelFernandez

    (@samuelfernandez)


    I see in the Checkbox only the Option: if selected, then show…

    But i wanna ask if this is possible: If the checkbox is activated, then change the value in field XYZ

Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @samuelfernandez

    If you want to display a specific value into a field depending on the choice selected in a checkbox field, you should use a calculated field.

    I’ll try to describe the process with a specific example:

    Assuming you have a checkbox field, the fieldname1, with three choices, one of them with the value: 123, and you want to display the value: 4321 into the fieldname5 field, if this choice is ticked by the user.

    Note, the values and fields’ names are hypothetical, only to describe the process.

    First, untick the checkbox: “Merge ticked up options (sum or concatenation) or their values are returned as an array” in the settings of the checkbox field. Now, the value of the checkbox field would be an array with the values of ticked choices.

    Second, if the fieldname5 is a calculated field, its equation can be implemented as follows:

    
    IF(IN(123,fieldname1), 4321, '')
    

    But if the fieldname5 is not a calculated field, for example, it is a number field. You should insert a calculated field as an auxiliary in the form, and its equation could be:

    
    getField(5).setVal(IF(IN(123,fieldname1), 4321, ''))
    

    Note 2: As the calculated field is being used as auxiliary, it is possible to hide it by ticking a checkbox in its settings.

    Note 3: The getField operation returns an object representation of the field, and receives as parameter the numeric part of the field’s name (in the example the number 5 by fieldname5)

    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘If the checkbox is activated, then change the value in field XYZ’ is closed to new replies.