...
This script uses a Text Component (checkState) to preserve the last selected Checkbox Component. Use two or more checkboxes (this example shows 3) and adjust the script accordingly. In general, you should use a Radio Component to achieve this functionality. This is an advanced script and it's very easy to miss updating a checkbox name, which can cause unexpected behavior. Be sure to carefully inspect your script for errors when deploying. A working form example is available here.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
//Add state control to checkboxes to mimic radio button behavior. if(data.check1 === true && (data.checkState == '2' || data.checkState == '3')) { value = '1'; data.check2 = false; data.check3 = false; } else if (data.check2 === true && (data.checkState == '1' || data.checkState == '3')) { value = '2'; data.check1 = false; data.check3 = false; } else if (data.check3 === true && (data.checkState == '1' || data.checkState == '2')) { value = '3'; data.check1 = false; data.check2 = false; } else if (data.check1 === true) value = '1'; else if (data.check2 === true) value = '2'; else if (data.check3 === true) value = '3'; else value = ''; |
...