Hello,
Apologies in advance this is a bit long...
If I have a checkbox..
- Checkbox_1
- (
- displayname = "Checkbox 1"
- type = checkboxes
- values = {"Option 1", "Option 2", "Option 3"}
- on user input
- {
- alert("In On User Input - input.Checkbox_1 is :" + input.Checkbox_1);
- }
- )
and a related Decision box...that gives the user the option to select or deselect all the strings in the checkbox in one step...
- Decision_box_1
- (
- displayname = "Decision box 1"
- type = checkbox
- defaultvalue = false
- on user input
- {
- if (input.Decision_box_1)
- {
- alert("In Select_Unselect FALSE, input.Participant_s is :" + input.Checkbox_1);
- Checkbox_1.deselectall();
- //Checkbox_1.getall();
- }
- else
- {
- alert("In Select_Unselect TRUE, input.Participant_s is :" + input.Checkbox_1);
- //Participant_s.selectall();
- for each x in input.Checkbox_1
- {
- alert("x is " + x);
- Checkbox_1.select(x);
- }
- //Checkbox_1.selectall();
- Checkbox_1.select("Option 1");
- Checkbox_1.select("Option 2");
- Checkbox_1.select("Option 3");
- alert("AFTER SELECTALL - In Select_Unselect TRUE, input.Participant_s is :" + input.Checkbox_1);
- }
- }
- )
Then...I have to manually select or deselect every string in the checkbox in order for this to work...because selectAll() and deselectAll() do NOT trigger the On User Input call associated with the checkbox.
In the example I provide above, that's OK...because I know the names of each string in the Checkbox and can loop through and set each one, BUT...if the list of items in the Checkbox is generated dynamically (using UI.add()), then I have no convenient way of knowing all of the strings that are in the Checkbox list...mainly because, whenever you refer to the Checkbox...it only returns to you the list of items that are Selected...
I hope I am making sense here...basically I can't select or deselect all of the strings in a for each loop because I don't have a list of them all - at any time I can only get access to a list of the ones that are currently selected.
I can get around this by storing the list of strings at the time of their being added to the checkbox...but that seems awkward.
It would be, if it's possible (or I have missed something) better to be able to get the full list of strings associated with the checkbox, but selected and unselected.
Any suggestions?
Liam