跳到主要内容

CreateCheckBoxForm

使用指定的复选框/单选按钮属性创建复选框/单选按钮。

语法

expression.CreateCheckBoxForm(formPr);

expression - 表示 Api 类的变量。

参数

名称必需/可选数据类型默认值描述
formPr必需CheckBoxFormPr复选框/单选按钮属性。

返回值

ApiCheckBoxForm

示例

在文档中添加复选框和单选按钮用于多选题。

// How do I insert checkboxes or radio buttons in a document?

// Create selectable options that let users pick from predefined choices in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);

let checkBoxForm = Api.CreateCheckBoxForm({
"key": "Marital status",
"tip": "Specify your marital status",
"required": true,
"placeholder": "Marital status",
"radio": true
});
paragraph.AddElement(checkBoxForm);
paragraph.AddText(" Married");
paragraph.AddLineBreak();

checkBoxForm = Api.CreateCheckBoxForm({
"key": "Marital status",
"tip": "Specify your marital status",
"required": true,
"placeholder": "Marital status",
"radio": true
});
paragraph.AddElement(checkBoxForm);
paragraph.AddText(" Single");
paragraph.AddLineBreak();

checkBoxForm = Api.CreateCheckBoxForm({
"key": "Children",
"tip": "Indicate if you have children",
"required": false,
"placeholder": "Children",
"radio": false
});
paragraph.AddElement(checkBoxForm);
paragraph.AddText(" Single");