Javascript: FormFieldCollection.addSelectionFormField Method
Description
Adds a new SelectionFormField.
Syntax
<void> FormFieldCollection.addSelectionFormField(<Number> emptyWidth, [<RequestSelectionFormFieldCallback> callback], [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| emptyWidth | Specifies the horizontal extension, in twips, of the SelectionFormField, when there is no selected item. When this parameter is set to 0, a default value is used. |
| callback | Optional. Receives the added SelectionFormField. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example inserts a priority drop-down field and selects its initial value.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
TXTextControl.textParts.getMainText(function(mainText) {
mainText.formFields.addSelectionFormField(1440, function(priorityField) {
priorityField.setItems(["Low", "Medium", "High"], function() {
priorityField.setSelectedIndex(1, function() {
console.log("Priority field added with Medium selected.");
}, onTxError);
}, onTxError);
}, onTxError);
}, onTxError);