setChoiceLabel( )
在计算的规则中使用此帮助程序函数将选择添加到现有选项(下拉列表、单选按钮或复选框)。
该表达式创建必须返回到目标控件的字符串 JSON 值,并且必须与 [Deprecated] - clearChoice( ) 结合使用。
如果要设置值而不是标签,请参见 setChoiceValue( ) 。
语法
setChoiceLabel(labelStr, variable)
参数
参数 | 必选/可选 | 说明 |
---|---|---|
labelStr |
必需 | 要为给定选项类型字段设置的标签的字符串值。 |
variable |
必需 | 与要设置的选项类型字段相对应的规则变量。 |
返回值
此函数返回 JSON 对象,其中包含所选选项的标签的字符串数组。如果未选择值,则返回空对象。
示例
示例 3-87 给定一个包含多个标签的下拉(选项)控件,包括“过敏”和“肥胖”作为计算规则的目标
// Select "Allergies"
if (someCondition) {
return setChoiceLabel("Allergies");
} else {
return clearChoice();
}
// selects "Allergies" in the calculated control
// Select "Allergies" and "Obesity"
var b;
if (someCondition) {
b = setChoiceLabel("Allergies");
return setChoiceLabel("Obesity", b);
} else {
return clearChoice();
}
// selects "Allergies" and "Obesity" in the calculated control
父主题:多个选项问题函数