跳到主要内容

SetGroupValue

选择组中具有指定选项名称的单选按钮。

语法

expression.SetGroupValue(value);

expression - 表示 ApiCheckBoxForm 类的变量。

参数

名称必需/可选数据类型默认值描述
value必需string要选择的单选按钮的选项名称。

返回值

boolean

示例

// The SetGroupValue method changes which radio button is selected across all buttons in the same group.

// Create two radio buttons in the same group, then select one using SetGroupValue.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let radio1 = Api.CreateCheckBoxForm({"tip": "Select your gender", "required": true, "placeholder": "Gender", "radio": true});
radio1.SetRadioGroup("Gender");
radio1.SetChoiceName("Male");
paragraph.AddElement(radio1);
paragraph.AddText(" Male");
paragraph.AddLineBreak();
let radio2 = Api.CreateCheckBoxForm({"tip": "Select your gender", "required": true, "placeholder": "Gender", "radio": true});
radio2.SetRadioGroup("Gender");
radio2.SetChoiceName("Female");
paragraph.AddElement(radio2);
paragraph.AddText(" Female");
radio1.SetGroupValue("Female");