Copy link to clipboard
Copied
Hi all,
I am trying to create a dropdown list with its selection generated from checkbox answers. For example if I tick 5 checkbox, the 5 answers from the checkbox will auto populate the dropdown list entries. I have attached the picture below to give an example of what I meant:
I have tried using the script below to do this but it doesn't work.
// Get the dropdown field
var dropdown = this.getField("Root Cause");
// Get the checkbox field
var checkbox = this.getField("Low learning aptitude");
if (checkbox.value === "Yes") {
var isOptionExists = false;
for (var i = 0; i < dropdown.numItems; i++) {
if (dropdown.getItemAt(i).value === optionValue) {
isOptionExists = true;
break;
}
}
if (!isOptionExists) {
var count = dropdown.numItems
dropdown.insertItemAt("People - Low learning aptitude","People - Low learning aptitude");
}
}
If anyone can help it would be much appreciated!
Copy link to clipboard
Copied
Check the JavaScript console for errors.
Copy link to clipboard
Copied
Collect checked answers into array and then set items to dropdown.
Copy link to clipboard
Copied
Give all of the checkboxes with a group name, for example "RootCauseQ.Low learning aptitude"
Then place the text you want displayed in the list for a particular checkbox, into the tooltip for that checkbox.
This code will collect the answers and fill the text box.
var aItemList = [];
var aCheckList = this.getField("RootCauseQ");
for(var i=0;i<aCheckList.length;i++)
{
if(aCheckList[i].value == "Yes")
aItemList.push(aCheckList[i].userName);
}
this.getField("Root Cause").setItems(aItemList);