Autocomplete functions - application possibilities

Examples for using autocomplete with source CSV or a database.

An autocomplete can be used with different predefined functions of FORMCYCLE. In the following examples the different possibilities are showed in detail.

Database query "states_data_starts_with":

SELECT name, id_state, capital, CONCAT(name,' (',capital, ')') as name_capital FROM state WHERE name LIKE CONCAT(?,'%') ORDER BY name;

Autocomplete with database - Example 1
Enable JavaScript to see the sample code

More information about autocompleteDB function can be found at the following link.

Autocomplete with database - Example 2
Enable JavaScript to see the sample code
Autocomplete with database - Example 3
Enable JavaScript to see the sample code
Autocomplete with database - Example 4
Enable JavaScript to see the sample code
Autocomplete with database - Example 5

The input city will be editable after a federal state is selected.

 

Database query "city_data_by_state_filtered" for tfCity:

SELECT name, id_city FROM city WHERE name LIKE  CONCAT(?,'%') AND id_state = ? ORDER BY name;

Enable JavaScript to see the sample code
Autocomplete with database in repeating container
Enable JavaScript to see the sample code

The following setting is completely possible via the Designer. The following steps are necessary:

  1. Add select field
  2. Add database data source without parameters or CSV data source
  3. Define label and value column
  4. Set field to autocomplete under basic properties
    (Is the same like using the function cob2auto)
Autocomplete in combination with select field

If the field is not set as required, you have to set the option show standard value, otherwise the value returned first will shown. The defined data source is database query "state_data":

SELECT name, id_state, capital FROM state ORDER BY name;