hub.eb?material_id=293&track_id=394

Executing Server-side Functions from the Browser


Functions in Scripts configured as Client Callable Functions can be called from the browser using the Client-Server API. These functions can take a parameter and return a value. 

Client Callable Functions are configured in the Events tab of a Form's Form Properties Icon Form Properties.

A function in a Client Callable Function Script can be called using the Client-Server API's executeFunction function, for example, $eb.executeFunction("myFunction"). This will execute the function named myFunction.

The following optional arguments can also be specified:

  • parameter pass some data to the function being executed.
  • autorefresh instructs the AJAX mechanism to refresh the Page with any changes made by the executed function.
  • fullSubmit validates and updates Field values before the function is executed.
  • failureCallback specify an error handling function to be called if the function cannot be executed.

Steps


1

Create a Form and add a Field called numbers. Set its Type to Numeric.

Drag the Field onto the Page and set the resultant Field Control to Display Only.

2

Create a Script containing a function that will set the numbers Field to a random integer using the following code:

function randomise(){
  fields.numbers.value = Math.random() * 99999;
}

Add the Script to the Form's Client Callable Functions.

3

Add a Button Control to your Page and set the text to Randomise.

Add an onclick HTML Event Handler in the Button Control's HTML Element Properties with the following code:

$eb.executeFunction('randomise', null, true)

 

4

Run the Form.

Clicking the button will generate some random numbers and display them in the Field Control.

Current Module

Part of tracks

Related