Survey123WebForm

Class

Survey123 Web form class.

Constructors

constructor

new Survey123WebForm(optionsSurvey123WebFormOptions): Survey123WebForm

Create a Survey123Webform instance.

For example:

     
var webform = new Survey123WebForm({
   clientId: "ABC1234567890",
   container: "formDiv",
   itemId: "129132bbedcb490488a162aa996b12323"
}
Parameters

Properties

options

Methods

copyFeature

copyFeature(globalIdstring): void

clone a feature from the related feature service of a survey the globalId of feature is required

Parameters
  • globalIdstring
Returns 
void

getContainer

getContainer(): any

Get Container.

Returns 
any

getForm

getForm(): Form

Get survey form. Only available after onFormLoaded().

Returns 
Form

getItemId

getItemId(): string

Get item id.

Returns 
string

getOptions

getOptions(key?string): any

Get options.

Parameters
  • keystringoptional 
Returns 
any

getQuestions

getQuestions(): any[]

Get questions in JSON format.

Returns 
any[]

setCredential

setCredential(credentialany): void

Set credential.

Parameters
  • credentialany
Returns 
void

setGeometry

setGeometry(geometryany): void

Dynamically set geometry on Map question. Only works if there is Map question in the survey. Supported formats are either GeoJSON, Esri Geometry Object, or XLSForm Geotrace/Geoshape format.

Parameters
  • geometryany

    For example:

                 
    webform.setGeometry(
       {
          "rings": [
           [
             [86.06251716611514, 56.9269796817211],
             [109.68749999997128, 53.72920275233425],
             [100.68750858304249, 50.2682616540679],
             [82.68752574918487, 49.543728300312914],
             [86.06251716611514, 56.9269796817211]
           ]
          ]
        }
    )
    
Returns 
void

setGeopoint

setGeopoint(geopointobject): void

Dynamically set coordinates on Geopoint question. Only works if there is Geopoint question in the survey.

Parameters
  • geopointobject
    Returns 
    void

    setItemId

    setItemId(itemIdstring): void

    Set item id. IFrame will be reloaded.

    Parameters
    • itemIdstring
    Returns 
    void

    setMode

    setMode(optionsobject): void

    Sets the mode of the web form. Valid values are edit, which sets the survey to edit an existing entry rather than create one, and view, which opens an existing entry in read-only mode, and copy, which will create a new web form that is populated with the contents from an existing entry. When setting the mode, the globalId parameter (version ≥ 3.9) or objectId(version ≤ 3.9) parameter must also be provided.

    For example:

        
    webform.setMode({
           mode: 'view',
           globalId: '<globalId>'
        })
    
    Parameters
    • optionsobject
      Returns 
      void

      setOnFormFailed

      setOnFormFailed(fxOnFormFailed): void

      Set OnFormResized event.

      Parameters
      • fxOnFormFailed
      Returns 
      void

      setOnFormLoaded

      setOnFormLoaded(fxOnFormLoaded): void

      Set OnFormLoaded event.

      Parameters
      • fxOnFormLoaded
      Returns 
      void

      setOnFormResized

      setOnFormResized(fxOnFormResized): void

      Set OnFormResized event.

      Parameters
      Returns 
      void

      setOnFormSubmitter

      setOnFormSubmitter(fxOnFormSubmitted): void

      Set OnFormSubmitter event.

      Parameters
      Returns 
      void

      setOnQuestionValueChanged

      setOnQuestionValueChanged(fxOnQuestionValueChanged): void

      Set OnQuestionValueChanged event.

      Parameters
      Returns 
      void

      setQuestionValue

      setQuestionValue(valueobject): void

      Dynamically set value on each question.

      Parameters
      • valueobject
        • [key: string]: any
      Returns 
      void

      setStyle

      setStyle(styleObjany): void

      Set CSS style.

      Parameters
      • styleObjany
      Returns 
      void

      setTheme

      setTheme(themeFormTheme): void

      Set form theme.

      Parameters
      • themeFormTheme

        For example:

                          
        {
           "header": {
             "backgroundColor": "#31872E",
             "textColor": "#ffffff"
           },
           "form": {
             "backgroundColor": "#ffffff",
             "backgroundOpacity": 1,
             "textColor": "#505050",
             "primaryColor": "#31872E",
             "primaryTextColor": "#ffffff",
             "inputTextColor": "#505050",
             "inputBackgroundColor": "#ffffff"
           },
           "webpage": {
             "backgroundColor": "#B7DCC7"
           }
        }
        
      Returns 
      void