hub.eb?material_id=373&track_id=368

JavaScript API: Fields


The fields interface acts as a parent for all Fields within a Form, Integration Service or Workflow Process. Individual Fields are accessed using their name e.g. fields.myField.

Field values are retrieved and set in script using the value property:

if(fields.age.value >= 18){
   fields.userType.value = "Adult";
}
else{
   fields.userType.value = "Child";
}

You can get the Field Control that displays a field on the current page using fields.myControl.getFieldControl(). If there are multiple Field Controls displaying a field then only the first will be returned. An optional page parameter can be passed to retrieve a Field Control from a specified page.

Steps


1

Create a Form and add a Field called currentDate and set the Field type to Date.

Drag the Field onto the page.

2

Add a before page event called setCurrentDate and add the following code:

fields.currentDate.value = new Date();
3

Return to the Form and run it.

The currentDate Field will have been set to the present date.

Current Module

Related