Skip to main content

CreateDropDownListContentControl

Creates a new drop-down list container with the given list of options.

Syntax

expression.CreateDropDownListContentControl(list, selected);

expression - A variable that represents a Api class.

Parameters

NameRequired/OptionalData typeDefaultDescription
listOptionalContentControlListItem[]An array of objects representing the items in the drop-down list.
selectedOptionalnumber-1The selected item index.

Returns

ApiInlineLvlSdt

Example

Add a drop-down list field with selectable options to a document.

// How do I insert a drop-down list field into a document?

// Give readers a fixed set of choices by embedding a drop-down list control in a document.

let doc = Api.GetDocument();
let cc = Api.CreateDropDownListContentControl([{display: 'one', value: '1'}, {display: 'two', value: '2'}], 1);
let paragraph = Api.CreateParagraph();
paragraph.Push(cc);
doc.Push(paragraph);