Dynamically Set a Select Field Value Using a Query Variable

You can use conditional logic to dynamically set the value of a select field from a query variable.

NOTE: Certain query variables are reserved by WordPress and will cause a redirect or 404 error. Please refer to the list of reserved query variables here.

For example, you might have a select field with the following values and labels:

WS Form PRO - Select Field - Options

Note that there are two columns:

  • Label – Shown to the user completing the form
  • Value – This is the select option value and is how we will reference that row

An example URL that could be used to set the select field might be:

https://mysite.com/my-form/?option=2

In this URL, we have a query variable with a name of option and a value of 2.

To use this query variable, you can use conditional logic as follows:

WS Form PRO - Select Field - Conditional Logic

Notice the use of the WS Form variable in the THEN action:

#query_var("option")

This sets the selected row with a value that matches the query variable name option.