GetFormsByTag

function GetFormsByTag(sTag: string = null): ApiBlockLvlSdt[] | ApiInlineLvlSdt[]

Description

Returns a list of all forms in the document with the specified tag name.

Parameters

sTagstringdefault: null

Form tag.

Returns

ApiBlockLvlSdt[] | ApiInlineLvlSdt[]

Try It

var oDocument = Api.GetDocument();
var oTextForm = Api.CreateTextForm({"key": "FirstName", "tip": "Enter your first name", "tag": "form_1", "required": true, "placeholder": "First name", "comb": true, "maxCharacters": 10, "cellWidth": 3, "multiLine": false, "autoFit": false});
var oParagraph = oDocument.GetElement(0);
oParagraph.AddElement(oTextForm);
var oComboBoxForm = Api.CreateComboBoxForm({"key": "Country", "tip": "Choose your country", "tag": "form_1", "required": true, "placeholder": "Country", "editable": false, "autoFit": false, "items": ["Latvia", "USA", "UK"]});
oParagraph.AddLineBreak();
oParagraph.AddElement(oComboBoxForm);
var aForms = oDocument.GetFormsByTag("form_1");
aForms[0].SetText("John Smith");
aForms[1].SelectListValue("USA");

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).