Filter a selection by a value

Enables parameterized database queries

This form illustrates how you can retrieve the options for a select field from a datasource, and add a filter to the database query. That can happen either when form is initially loaded, or triggered when the user enters a value into a form field.

 

Currently, only selection lists can be filtered. Radiobutton and checkbox lists are not supported!

 

Important: This demo form requires an additional script to work correctly. You can download it via the following button. Then upload the script under Files & Templates > Files or directly at the form under Files.

Initally filtered list

Name of the field is a combination of the corresponding selection and "DisplayValue". Only if the name fits, works the setting of the data!

Name of the field is a combination of the corresponding selection and "Value". Only if the name fits, works the setting of the data!

Enable JavaScript to see the sample code

Database query "states_data_two_placeholders":

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


Combined lists
Enable JavaScript to see the sample code

Database query "city_data_by_state":

SELECT name, id_city FROM city WHERE id_state = ? ORDER BY name;


Initially filtered list with repeated elements

Name of the field is a combination of the corresponding selection and "DisplayValue". Only if the name fits, works the setting of the data!

Name of the field is a combination of the corresponding selection and "Value". Only if the name fits, works the setting of the data!

Enable JavaScript to see the sample code

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;

powered by XIMA® formcycle