I have 4 checkboxes and a text field. If the user selects checkbox1, I want “1” to display in the text field. If the user selects checkbox2, I want “2” to display in the text field. And so on…
I have the following code written in the expression binding of the text field:
So I am creating a “service report” and the 4 checkboxes represent different types of equipment. When a user is filling out the service report, they select the checkbox(s) based on the equipment they worked on. The text field that is displaying the selected values, won’t be in the final design. Instead, I will just be writing the value, of the selected checkbox(s), to a parameter and then passing the parameter to a table which displays the information entered in the service report. I was only using the text field for development purposes, to get the functionality working.
Add a custom value property to each of the checkboxes. Name it whatever you want. key is the default and is fine. Set the value to the “weight” of that checkbox.
Create an expression binding on the component to track the total.
So you’re encoding the parameter state, then unpacking it at the other end.
You could do that (unambiguously) using binEnums sibling function, binEnc - which packs a set of bits into binary, then returns the integer representation.
However, you really probably don’t need it. Parameters are free. I would just add parameters for each of these input parameters. It’s going to be a lot easier to reason about down the road.