Skip to content
GPLWP Guides

How to create dependent dropdowns in WordPress forms

Forms Time About 30–60 minutes manually, or 15 minutes with a suitable form plugin 6 steps Updated 18 Sep 2026

FORMS
The short answer

WordPress does not provide dependent dropdowns as a general form feature. For a small fixed list, connect two select fields with JavaScript; for database-driven options, use AJAX through WordPress. A hierarchical-select plugin is the faster route for complex forms.

The route
  1. 01Plan the dropdown relationship
  2. 02Add the parent and child fields
  3. 03Connect small lists with JavaScript
  4. 04Use WordPress AJAX for dynamic data
  5. 05Validate the submitted relationship
  6. 06Choose the fast plugin route

What you need

  • A WordPress form plugin or a custom form template
  • Admin or code access to the site
  • A defined parent-to-child data relationship
  • A staging site for testing changes

Plan the dropdown relationship

Decide which field controls the next one. For example, Country controls State, and State controls City. Give every option a stable value, such as a term ID or database ID, rather than relying on the displayed label.

Choose JavaScript for a short, fixed list. If the child options come from posts, terms, products, users or another large data set, use an AJAX request so you do not load every option into the page at once. This is the usual distinction made in WordPress support discussions about cascading dropdowns.

Add the parent and child fields

Add one select field for the parent and another for the child in your form builder. Give them clear field names or IDs, such as country and state. Add a first option such as “Select a country” and leave the child field empty or disabled until a parent value is chosen.

Make the child field required only when it has valid options. When the parent changes, clear the old child value before adding the new options. Otherwise, a previously selected child can remain visible or be submitted even though it no longer belongs to the selected parent.

Connect small lists with JavaScript

For a small, rarely changing list, store the relationship in a JavaScript object and listen for the parent select’s change event. Empty the child select, add a placeholder, then loop through the matching child options and append them to the field.

Disable the child field while no parent is selected and enable it after options are added. This method is simple and avoids a server request, but every data change requires editing the script. It also becomes slow and difficult to maintain when the list contains hundreds or thousands of records.

Use WordPress AJAX for dynamic data

For database-backed options, send the selected parent ID to wp-admin/admin-ajax.php. WordPress AJAX requests need an action value; register the matching wp_ajax_{$action} handler for logged-in users and wp_ajax_nopriv_{$action} as well if visitors can use the form.

Enqueue the JavaScript with wp_enqueue_script(), pass the AJAX URL and a nonce with wp_localize_script(), and verify the request with check_ajax_referer(). Sanitize the parent value, query only its children, return the options as JSON, and rebuild the child select in the browser.

Validate the submitted relationship

Do not trust the browser’s dropdown choices. On submission, verify that the selected child really belongs to the selected parent. A user can bypass JavaScript or send a forged request directly to the form endpoint.

Also check that the dynamically added option has the field name expected by your form plugin. A common failure is that the option appears on screen but is missing from the saved entry because the plugin only accepts registered field values. Some plugins require their own API or documented field-update method instead of direct DOM changes.

Choose the fast plugin route

If you need several levels, editable relationships or non-technical administration, use a form extension that supports hierarchical or chained selects instead of maintaining custom JavaScript and AJAX handlers.

JetFormBuilder Hierarchical Select is a suitable option when your form uses category-to-subcategory choices. It adds multi-level selections, conditional behaviour and dynamic option population within JetFormBuilder forms, reducing the amount of custom code you need to maintain.

The fast route

Let JetFormBuilder Hierarchical Select do it

Adds multi-level, conditional selects to JetFormBuilder forms, ideal when users need category-to-subcategory choices.

Get JetFormBuilder Hierarchical Select

Sources

  1. wordpress.org /support/topic/conditional-or-nonconditional-search-form-bas…
  2. developer.wordpress.org /plugins/javascript/ajax/?utm_source=openai
  3. wordpress.org /support/topic/input-field-populated-with-jquery-are-not-app…
  4. wordpress.org /support/topic/dropdown-menu-90/?utm_source=openai
  5. wordpress.org /support/topic/find-script-issue/?utm_source=openai

Questions

Can WordPress create dependent dropdowns without a plugin?
Yes, but WordPress does not supply a universal dependent-dropdown setting for forms. You can connect two native select fields with JavaScript when the options are small and fixed. For options stored in WordPress, you normally add an AJAX handler that queries the child records and returns them to the browser. The manual route needs custom code, validation and ongoing maintenance.
Should I use JavaScript or AJAX for dependent dropdowns?
Use JavaScript when the complete parent-to-child list is small, stable and safe to send to every visitor. Use AJAX when the options come from posts, taxonomies, products or a large database table. AJAX keeps the initial page smaller, but it requires a WordPress endpoint, request security, error handling and server-side validation.
Why does the child dropdown show options but not save the value?
The child dropdown may be displaying a value that the form plugin does not recognise as one of its registered options. Some builders validate fields against their internal configuration, so changing the HTML alone is not enough. Use the builder’s documented field-update method where available, and confirm the submitted field name, value and option format in the browser’s request data.
Why does a dependent dropdown work in preview but fail on the live page?
The live page may not be loading the JavaScript, the form may have been embedded incorrectly, or another theme or plugin script may be replacing the select element. Check the browser console and network panel, confirm that the form’s scripts are enqueued on the public page, and check whether caching, minification, security rules or ModSecurity is blocking the AJAX request.
Do I need to reset the child field when the parent changes?
Yes. Clear the child field and its selected value whenever the parent changes, then load the new child options. If you leave the old value in place, the form can submit a child belonging to the previous parent. If the child select is disabled during loading, enable it before submission because disabled form controls are not included in the submitted form data.