Use URL parameters in SQL

Introduction

Note: These features are part of the Visforms Subscription and are not included in the free Visforms version.

The path of a value from a GET URL parameter to the SQL statement of an SQL field is possible. This also applies to the initial display of the form.

To do this, you have to combine 2 features:

Note: Below is a small form for demonstration.

The fields involved

Field text-1

It has field type Text.
The field contains the back part of the URL of the form call.

Field number-1

It has field type Number.
The field contains the value from the URL of the form call as the starting value.

The necessary field configuration, tab ‘Advanced’ is:

  • ‘Allow Url Parameter’ = ‘Yes’.

Field sql-select-1

It has the field type Listbox SQL.
The field shows the name of the form with the ID from the ‘number-1’ field.

The necessary field configuration, tab ‘Basic settings’ is:

  • ‘Preselect solitary option’ = ‘Yes’,
  • ‘Reload when changing’ = ‘number-1’,
  • ‘SQL-Select-Statement’ = ‘select id as value, name as label from #__visforms where id = ${input:number-1};'.
select id as value, name as label from #__visforms where id = ${input:number-1};

The form

The form when initially displayed

The form during the initial display

The form after manual selection ‘number1’ = 11

The form after the manual selection 'number1' = 11

Additional display options

There are other display options:

  • Completely hide the text-1 field in the form so that it does not appear in the form.
  • The sql-select-1 field
    • to deactivate in his selection,
    • no longer display as a selectable list box, so that it appears somewhat like static text,
    • to hide it completely.