Survey123WebForm
Class
Survey123 Web form class.
Constructors
constructor
Class Constructornew Survey123WebForm(options: Survey123WebFormOptions): Survey123WebForm
Create a Survey123Webform instance.
For example:
Parameters
Parameter | Type | Notes |
---|---|---|
options | Survey123WebFormOptions |
Returns
Survey123WebForm
Properties
Property | Type | Notes |
---|---|---|
Methods
Method | Returns | Notes |
---|---|---|
addRepeat(options) | Promise<any> | Add repeat record. For example: |
collapse(name) | void | Collapse group or repeat question. |
copyFeature(globalId) | void | Clone a new web form that is populated with the contents from an existing entry by the globalId. |
deleteRepeat(options) | Promise<any> | Delete repeat record. For example: |
expand(name) | void | expand group or repeat |
any | Get Container. | |
getForm() | Form | Get survey form. Only available after onFormLoaded(). |
string | Get item id. | |
getOptions(key?) | any | Get options. |
Promise<QuestionValue> | Get question value. | |
any[] | Get questions in JSON format. | |
getRepeatCount(questionName) | Promise<number> | Get the count of records in a repeat question. For example: |
off(eventName, callback) | void | Remove registered event.Supported with version ≥ 3.14 |
on(eventName, callback) | void | Register event listener. Supported with version ≥ 3.14. Valid event names are:
|
scrollTo(name) | void | Scroll to a question. |
setCredential(credential) | void | Set credential. |
setGeometry(geometry) | 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. |
setGeopoint(geopoint) | void | Dynamically set coordinates on Geopoint question. Only works if there is Geopoint question in the survey. |
setItemId(itemId) | void | Set item id. IFrame will be reloaded. |
setMode(options) | void | Sets the mode of the web form. Valid values are
|
setOnFormFailed(fx) | void | Set OnFormFailed event. For example: |
setOnFormLoaded(fx) | void | Set OnFormLoaded event. For example: |
setOnFormResized(fx) | void | Set OnFormResized event. For example: |
void | Set OnFormSubmitted event. For example: | |
void | Set OnQuestionValueChanged event. For example: | |
setQuestionValue(value) | void | Dynamically set value on each question. |
setStyle(styleObj) | void | Set CSS style of any UI element using the JSS syntax. |
setTheme(theme) | void | Set form theme. |
void | Submit the survey based on the current question values. |
addRepeat
Class MethodaddRepeat(options: { count?: number[]; questionName: string; questionValues?: any[] }): Promise<any>
Add repeat record. For example:
Parameters
Parameter | Type | Notes |
---|---|---|
options | { count?: number[]; questionName: string; questionValues?: any[] } |
Returns
Promise<any>
collapse
Class Methodcollapse(name: string): void
Collapse group or repeat question.
Parameters
Parameter | Type |
---|---|
name | string |
Returns
void
copyFeature
Class MethodcopyFeature(globalId: string): void
Clone a new web form that is populated with the contents from an existing entry by the globalId.
Parameters
Parameter | Type |
---|---|
global | string |
Returns
void
deleteRepeat
Class MethoddeleteRepeat(options: { indexes?: number[]; questionName: string }): Promise<any>
Delete repeat record. For example:
Parameters
Parameter | Type | Notes |
---|---|---|
options | { indexes?: number[]; questionName: string } |
Returns
Promise<any>
expand
Class Methodexpand(name: string): void
expand group or repeat
Parameters
Parameter | Type |
---|---|
name | string |
Returns
void
getContainer
getContainer(): any
Get Container.
Returns
any
getItemId
getItemId(): string
Get item id.
Returns
string
getOptions
getOptions(key?: string): any
Get options.
Parameters
Parameter | Type | Notes |
---|---|---|
key | string |
Returns
any
getQuestionValue
Class MethodgetQuestionValue(): Promise<QuestionValue>
Get question value.
Returns
Promise<QuestionValue>
getRepeatCount
Class MethodgetRepeatCount(questionName: string): Promise<number>
Get the count of records in a repeat question. For example:
Parameters
Parameter | Type | Notes |
---|---|---|
question | string |
Returns
Promise<number>
off
Class Methodoff(eventName: string, callback: EventFunction): void
Remove registered event.Supported with version ≥ 3.14
Parameters
Parameter | Type | Notes |
---|---|---|
event | string | |
callback | EventFunction |
Returns
void
on
Class Methodon(eventName: string, callback: EventFunction): void
Register event listener. Supported with version ≥ 3.14. Valid event names are:
- formLoaded, which will be triggered when the form is fully loaded.
- formResized, which will be triggered when the form is resized.
- formSubmitted, which will be triggered when the response is submitted.
- questionValueChanged, which will be triggered when the question value is changed.
- repeatIndexChanged, which will be triggered when the active repeat record is changed.
- propertyChanged, which will be triggered when the locale or theme of the web app is changed.
Parameters
Parameter | Type | Notes |
---|---|---|
event | string | |
callback | EventFunction |
Returns
void
scrollTo
Class MethodscrollTo(name: string): void
Scroll to a question.
Parameters
Parameter | Type | Notes |
---|---|---|
name | string |
Returns
void
setCredential
setCredential(credential: any): void
Set credential.
Parameters
Parameter | Type | Notes |
---|---|---|
credential | any |
Returns
void
setGeometry
Class MethodsetGeometry(geometry: any): 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.
For example:
Parameters
Parameter | Type | Notes |
---|---|---|
geometry | any |
Returns
void
setGeopoint
Class MethodsetGeopoint(geopoint: { x: number; y: number }): void
Dynamically set coordinates on Geopoint question. Only works if there is Geopoint question in the survey.
Parameters
Parameter | Type | Notes |
---|---|---|
geopoint | { x: number; y: number } |
Returns
void
setItemId
setItemId(itemId: string): void
Set item id. IFrame will be reloaded.
Parameters
Parameter | Type | Notes |
---|---|---|
item | string |
Returns
void
setMode
Class MethodsetMode(options: { globalId?: string; mode: string; objectId?: string }): 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:
Parameters
Parameter | Type |
---|---|
options | { globalId?: string; mode: string; objectId?: string } |
Returns
void
setOnFormFailed
Class MethodsetOnFormFailed(fx: OnFormFailed): void
Set OnFormFailed event. For example:
Parameters
Parameter | Type | Notes |
---|---|---|
fx | OnFormFailed |
Returns
void
setOnFormLoaded
Class MethodsetOnFormLoaded(fx: OnFormLoaded): void
Set OnFormLoaded event. For example:
Parameters
Parameter | Type | Notes |
---|---|---|
fx | OnFormLoaded |
Returns
void
setOnFormResized
Class MethodsetOnFormResized(fx: OnFormResized): void
Set OnFormResized event. For example:
Parameters
Parameter | Type | Notes |
---|---|---|
fx | OnFormResized |
Returns
void
setOnFormSubmitted
Class MethodsetOnFormSubmitted(fx: OnFormSubmitted): void
Set OnFormSubmitted event. For example:
Parameters
Parameter | Type | Notes |
---|---|---|
fx | OnFormSubmitted |
Returns
void
setOnQuestionValueChanged
Class MethodsetOnQuestionValueChanged(fx: OnQuestionValueChanged): void
Set OnQuestionValueChanged event. For example:
Parameters
Parameter | Type | Notes |
---|---|---|
fx | OnQuestionValueChanged |
Returns
void
setQuestionValue
Class MethodsetQuestionValue(value: { [key: string]: any }): void
Dynamically set value on each question.
For example:
Parameters
Parameter | Type |
---|---|
value | { [key: string]: any } |
Returns
void
setStyle
Class MethodsetStyle(styleObj: any): void
Set CSS style of any UI element using the JSS syntax.
For example:
Parameters
Parameter | Type |
---|---|
style | any |
Returns
void
options: Survey123WebFormOptions