Filling out the form

Fills in the empty cells in the form.

The user can choose a username from the list and all the fields in the form editor will be filled with the user contact information. At the same time, this data is displayed in the inputs of the custom interface.

When the user edits the input data in the custom interface, it is automatically updated in the form editor as well.

When the document is ready, it can be downloaded by clicking the Download button and printed.

Choose Example Isabella Robinson Emma Smith Emily Williams Sophia Brown Olivia Davis Abigail Jones Davis Hannah Samantha Smith Mia Davis Madison Taylor Jacob Brown Jason Davis Michael Williams Christopher Johnson Ethan Taylor Daniel Wright Matthew Jones Andrew Wilson William Robinson Joshua Johnson

How it works

  1. When the user opens a form document, the GetAllContentControls method is executed to collect all the content controls from the document. After that, the GetFormValue method is executed to get the content controls values and display them in the custom interface:

    1. var contentControls = [];
    2. var onDocumentReady = function () {
    3. window.connector = docEditor.createConnector();
    4. connector.executeMethod("GetAllContentControls", null, function (data) {
    5. setTimeout(function () {
    6. for (let i = 0; i < data.length; i++) {
    7. ...
    8. connector.executeMethod("GetFormValue", [data[i]["InternalId"]], function (value) {
    9. data[i].Value = value ? value : "";
    10. if (data.length - 1 == i) {
    11. contentControls = data;
    12. ...
    13. }
    14. });
    15. }
    16. }, 0);
    17. });
    18. };
  2. When the user chooses a username from the list, the GetFormsByTag method is executed to collect all the forms by their tags and sets the corresponding values to them with the SetFormValue method:

    1. $("#persons").change(function (e) {
    2. const postalCode = $(this).val();
    3. $.getJSON("/app_data/editor/wildcarddata/persons.json", function (persons) {
    4. for (const person of persons) {
    5. if (person["PostalCode"] == postalCode) {
    6. for (key in person) {
    7. var value = person[key];
    8. ...
    9. setFormValue(key, value);
    10. }
    11. }
    12. }
    13. })
    14. var setFormValue = function (tag, value) {
    15. connector.executeMethod(
    16. "GetFormsByTag",
    17. [tag],
    18. function (forms) {
    19. connector.executeMethod(
    20. "SetFormValue",
    21. [forms[0]["InternalId"], value],
    22. null
    23. );
    24. }
    25. );
    26. }
    27. });
  3. When the user edits a form value, the onChangeContentControl event is fired and after that, the GetFormValue method is executed to get an updated form value and display it in the custom interface:

    1. var onDocumentReady = function () {
    2. ...
    3. connector.attachEvent("onChangeContentControl", onChangeContentControl);
    4. ...
    5. };
    6. function onChangeContentControl(e) {
    7. connector.executeMethod("GetFormValue", [e["InternalId"]], function (value) {
    8. ...
    9. $("#" + e["InternalId"]).val(value || "");
    10. ...
    11. });
    12. }

Getting help

If you have any questions, ask our developers on ONLYOFFICE forum (registration required).