Datapolis Process System
Javascript 'onchange' in form fields
This walkthrough will show you how to create dynamically changing form fields using javascript onchange function. This example contains a check box which disables one of the other controls by clicking.
The end result looks like this:
Creating workflow
Editing form fields
Now add the logic behind controls. Click edit on checked variable, go to the Javascript section and type name for Client 'onchange' function.
In this example we named it chacked_onchange.
Additionally you can edit form field name and description so that the form has more refined look.
Javascript code
As you can see, there are now two functions: _dp_onAfterFormLoaded() and checked_onchange(field, args). For us the latter is more interesting.
Paste there the following code:
function
checked_onchange(field, args) {
var
form = Datapolis.Forms.currentForm;
address1 = form.fields[
"address1"
];
address2 = form.fields[
"address2"
address2.value(args.value?address1.value():
''
);
address2.enable(!args.value);
}
Args.value indicates whether the checkbox is checked or not. Function copies the content of first textbox to the second one and disables it.
For more information check out our Javascript Object Model reference.
Deploy and run
Download