PHPackages                             smarek/jquery-chained-selects - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. smarek/jquery-chained-selects

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

smarek/jquery-chained-selects
=============================

jQuery plugin to create chained selects from hierarchical JSON data

v2.1.1(2y ago)6161MITJavaScript

Since Dec 6Pushed 2y ago2 watchersCompare

[ Source](https://github.com/smarek/jquery-chained-selects)[ Packagist](https://packagist.org/packages/smarek/jquery-chained-selects)[ RSS](/packages/smarek-jquery-chained-selects/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (11)Used By (0)

Chained Selects
===============

[](#chained-selects)

jQuery plugin for populating chained selects using hierarchical javascript (JSON) data

Sample usage
------------

[](#sample-usage)

[Demo can be seen here](https://smarek.github.io/jquery-chained-selects/demo.html)

```

var chainedData = {
    "A": {
        1: "AA",
        2: "AB"
    },
    "B": {
        "BB": {
            3: "BBB"
        }
    }
};

$(document).ready(function () {
    $('#sample-select').chainedSelects({
        data: chainedData,
        loggingEnabled: true
    });
});

```

Full options
------------

[](#full-options)

```
$("#select-id").chainedSelects({
    placeholder: "", // placeholder text, can be left empty, default value is "", if the placeholder is empty, no empty option will be created
    selectCssClass: "my-select-extra-css-class", // extra css class to add on used/generated html select elements, defaults to `false`
    data: dataVariable, // data, can be function which returns data structure, or plain variable, defaults to `{}`
    maxLevels: 10, // to avoid browser hangs, by default is limited to 10 levels of hierarchy, you can raise this if you need to
    loggingEnabled: false, // enables internal logging, might be useful for debugging, defaults to `false`
    selectedKey: 3, // will pre-select options by option value, accepts numeric or string (string for selecting either category, number for the final option), default to `false`
    // IMPORTANT: selectedKey option will override defaultPath option
    defaultPath: ["B", "BB"], // will pre-select options by path, defaults to `false`
    sortByValue: false, // sort options by text value, defaults to `false`
    // IMPORTANT: if provided callback function fails, it will not report caught error if the `loggingEnabled` is not `true`
    onSelectedCallback: function(id){}, // will call user defined function with id of currently selected, or empty string if non-final option was chosen, defaults to `false`
    autoSelectSingleOptions: true, // will automatically select single options at any level (recursively), forcing user to make a choice only when there is choice to make, defaults to `false`
});
```

API Methods
-----------

[](#api-methods)

```
// Set logging enabled (true or false, in case of invalid argument, defaults to true)
$("#select-id").data("chainedSelects").setLoggingEnabled(boolean);
// Change current selected key (integer or string, for either specific choice or category)
$("#select-id").data("chainedSelects").changeSelectedKey(newSelectedKey);
```

Notes about usage
-----------------

[](#notes-about-usage)

- Will not allow you to select parent, only values where key is numeric (in sample selectable only 1(AA), 2(AB) and 3(BBB)
- Will bind to form surrounding the target select, and before form submit, place dummy option with selected value to the target select

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~193 days

Recently: every ~366 days

Total

10

Last Release

969d ago

Major Versions

v1.0.4 → v2.0.02019-07-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/e6f23656b2f2edeb25d3996f52c17b15597554173d7a06e121e755032e45c999?d=identicon)[smarek](/maintainers/smarek)

---

Top Contributors

[![smarek](https://avatars.githubusercontent.com/u/384824?v=4)](https://github.com/smarek "smarek (19 commits)")

---

Tags

pluginjqueryselectjquery-pluginchainedselects

### Embed Badge

![Health badge](/badges/smarek-jquery-chained-selects/health.svg)

```
[![Health](https://phpackages.com/badges/smarek-jquery-chained-selects/health.svg)](https://phpackages.com/packages/smarek-jquery-chained-selects)
```

###  Alternatives

[snapappointments/bootstrap-select

The jQuery plugin that brings select elements into the 21st century with intuitive multiselection, searching, and much more. Now with Bootstrap 4 support.

9.8k480.4k3](/packages/snapappointments-bootstrap-select)[froala/wysiwyg-editor

A beautiful jQuery WYSIWYG HTML rich text editor. High performance and modern design make it easy to use for developers and loved by users.

5.4k306.9k3](/packages/froala-wysiwyg-editor)[onokumus/metismenu

A jQuery menu plugin

2.0k263.3k5](/packages/onokumus-metismenu)[kartik-v/dependent-dropdown

A multi level dependent dropdown JQuery plugin that allows nested dependencies.

1805.0M3](/packages/kartik-v-dependent-dropdown)[kartik-v/yii2-widget-datepicker

Enhanced Yii2 wrapper for the bootstrap datepicker plugin (sub repo split from yii2-widgets).

1097.0M59](/packages/kartik-v-yii2-widget-datepicker)[kartik-v/yii2-widget-datetimepicker

Enhanced Yii2 wrapper for the bootstrap datetimepicker plugin (sub repo split from yii2-widgets)

1036.5M47](/packages/kartik-v-yii2-widget-datetimepicker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
