Survey123WebForm
Class
Survey123 Web form class.
Constructors
new Survey123WebForm(options: Survey123WebFormOptions): Survey123WebForm
Create a Survey123Webform instance.
For example:
Parameters
Parameter | Type |
---|---|
options | Survey123WebFormOptions |
Returns
Survey123WebForm
Properties
Property | Type |
---|---|
options
Methods
Method | Returns | Notes |
---|---|---|
| Promise<any> | Add repeat record. |
| void | Collapse group or repeat question. |
| void | Clone a new web form that is populated with the contents from an existing entry by the globalId. |
| Promise<any> | Delete repeat record. |
| void | expand group or repeat |
| any | Get Container. |
| Form | Get survey form. Only available after onFormLoaded(). |
| string | Get item id. |
| any | Get options. |
| Promise<QuestionValue> | Get question value. |
| any[] | Get questions in JSON format. |
| Promise<number> | Get the count of records in a repeat question. |
| void | Remove registered event. |
| void | Register event listener. Valid event names are:
|
| void | Scroll to a question. |
| void | Set credential. |
| 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. |
| void | Dynamically set coordinates on Geopoint question. Only works if there is Geopoint question in the survey. |
| void | Set item id. IFrame will be reloaded. |
| void | Sets the mode of the web form. Valid values are
|
| void | Set OnFormFailed event. |
| void | Set OnFormLoaded event. |
| void | Set OnFormResized event. |
| void | Set OnFormSubmitted event. |
| void | Set OnQuestionValueChanged event. |
| void | Dynamically set value on each question. |
| void | Set CSS style of any UI element using the JSS syntax. |
| void | Set form theme. |
| void | Submit the survey based on the current question values. |
addRepeat
addRepeat(options: { count?: number[]; questionName: string; questionValues?: any[] }): Promise<any>
Add repeat record.
Parameters
Parameter | Type | Notes |
---|---|---|
options | { count?: number[]; questionName: string; questionValues?: any[] } | For example: |
Returns
Promise<any>
collapse
collapse(name: string): void
Collapse group or repeat question.
Parameters
Parameter | Type |
---|---|
name | string |
Returns
void
copyFeature
copyFeature(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
deleteRepeat(options: { indexes?: number[]; questionName: string }): Promise<any>
Delete repeat record.
Parameters
Parameter | Type | Notes |
---|---|---|
options | { indexes?: number[]; questionName: string } | For example: |
Returns
Promise<any>
expand
expand(name: string): void
expand group or repeat
Parameters
Parameter | Type |
---|---|
name | string |
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
Parameter | Type |
---|---|
key | string |
Returns
any
getQuestionValue
getQuestionValue(): Promise<QuestionValue>
Get question value.
Returns
Promise<QuestionValue>
getQuestions
getQuestions(): any[]
Get questions in JSON format.
Returns
any[]
getRepeatCount
getRepeatCount(questionName: string): Promise<number>
Get the count of records in a repeat question.
Parameters
Parameter | Type | Notes |
---|---|---|
question | string | For example: |
Returns
Promise<number>
off
off(eventName: string, callback: EventFunction): void
Remove registered event.
Parameters
Parameter | Type |
---|---|
event | string |
callback | EventFunction |
Returns
void
on
on(eventName: string, callback: EventFunction): void
Register event listener. Valid event names are:
- 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 |
---|---|
event | string |
callback | EventFunction |
Returns
void
scrollTo
scrollTo(name: string): void
Scroll to a question.
Parameters
Parameter | Type |
---|---|
name | string |
Returns
void
setCredential
setCredential(credential: any): void
Set credential.
Parameters
Parameter | Type |
---|---|
credential | any |
Returns
void
setGeometry
setGeometry(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.
Parameters
Parameter | Type | Notes |
---|---|---|
geometry | any | For example: |
Returns
void
setGeopoint
setGeopoint(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 |
---|---|
geopoint | { x: number; y: number } |
Returns
void
setItemId
setItemId(itemId: string): void
Set item id. IFrame will be reloaded.
Parameters
Parameter | Type |
---|---|
item | string |
Returns
void
setMode
setMode(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
setOnFormFailed(fx: OnFormFailed): void
Set OnFormFailed event.
Parameters
Parameter | Type | Notes |
---|---|---|
fx | OnFormFailed | For example: |
Returns
void
setOnFormLoaded
setOnFormLoaded(fx: OnFormLoaded): void
Set OnFormLoaded event.
Parameters
Parameter | Type | Notes |
---|---|---|
fx | OnFormLoaded | For example: |
Returns
void
setOnFormResized
setOnFormResized(fx: OnFormResized): void
Set OnFormResized event.
Parameters
Parameter | Type | Notes |
---|---|---|
fx | OnFormResized | For example: |
Returns
void
setOnFormSubmitted
setOnFormSubmitted(fx: OnFormSubmitted): void
Set OnFormSubmitted event.
Parameters
Parameter | Type | Notes |
---|---|---|
fx | OnFormSubmitted | For example: |
Returns
void
setOnQuestionValueChanged
setOnQuestionValueChanged(fx: OnQuestionValueChanged): void
Set OnQuestionValueChanged event.
Parameters
Parameter | Type | Notes |
---|---|---|
fx | OnQuestionValueChanged | For example: |
Returns
void
setQuestionValue
setQuestionValue(value: { [key: string]: any }): void
Dynamically set value on each question.
For example:
Parameters
Parameter | Type |
---|---|
value | { [key: string]: any } |
Returns
void
setStyle
setStyle(styleObj: any): void
Set CSS style of any UI element using the JSS syntax.
For example:
Parameters
Parameter | Type |
---|---|
style | any |
Returns
void
setTheme
setTheme(theme: FormTheme): void
Set form theme.
Parameters
Parameter | Type | Notes |
---|---|---|
theme | FormTheme | For example: |
Returns
void
submitForm
submitForm(): void
Submit the survey based on the current question values.
Returns
void
options: Survey123WebFormOptions