DMXzone Server Connect Manual

November 23, 2015
Filtering a query with a form field
Filtering a query with a form field

With this movie we will show you how to filter a database query, using a form field.

Step by Step

We will show you how to filter a database query, using a form field. You already learned how to create a database query and show your records, within a repeat region, on your page. We are listing our products on the page, but we'd like to be able to filter them by name. That's why we added a simple text field on our page. We change its default name to search. Now, we need to edit our database query, and add a filter.

First, we add a global variable, which will be used to filter the query. We will assign the search field value to this global variable. Right click get, under globals. And add variable. Let's call this variable search (1). Save your action file (2). And select your database query, under the server action steps (3). Open the query options (4).

And open the Filters tab (1). Select the column, you want to filter your query by (2). And add it to the filters list. Select a condition, for this filter. We select contains (3). Then, click the server data bindings button, to assign a value to this filter (4).

Select the get variable, that we created earlier (1). then click the select button (2).

Click Ok to apply this filter. And save your action file (1). The only thing, that's left is to assign the text field value to our get variable. Select the server action executor (2). And click the edit button. Click the search variable, under the input data tab (3). then select the text field, which we named search, under the global form variables (4). And assign this text field value, to the variable (5). Then, check the refresh the action data, when this value changes checkbox (6).

Let's preview the results. That's how easy it is to filter a database query, using a form field.