dependent-select-boxes
v1.0.0
Published
Allows a child select box to change its options dependent on its parent select box
Downloads
4
Maintainers
Readme
dependent-select-boxes
dependent-select-boxes
allows a child select box to change its options dependent on its parent select box.
Additional options
You can pass in options as a third parameter. The currently supported options are:
childOptionIsDependentOnParentOption(childOption, parentOption)
: Function that determines if thechildOption
should be displayed ifparentOption
is selected. Default:true
if the value of the parent option is a prefix of the value of the child option, elsefalse
.resetParentOptionOnEmptyChildOption
: Resets the parent option to an empty value if the child option changes to an empty option. Defaulttrue
.
new DependentSelectBoxes(document.getElementById('parent'), document.getElementById('child'), {
childOptionIsDependentOnParentOption(childOption, parentOption) {
...
},
resetParentOptionOnEmptyChildOption: false,
});
You can configure the default options by setting them via:
import { setDefaultOptions } from 'dependent-select-boxes';
setDefaultOptions({
...
});
Node
// npm install dependent-select-boxes --save
import DependentSelectBoxes from 'dependent-select-boxes';
const dependentSelectBoxes = new DependentSelectBoxes(parent, child, options);
Contributing
If you would like to submit a pull request
with any changes you make, please feel free!
Simply run npm test
to test and npm start
to compile before submitting pull requests.
Issues
Please use the GitHub issue tracker to raise any problems or feature requests.