1.0.0 • Published 8 years ago

dependent-select-boxes v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

dependent-select-boxes

dependent-select-boxes allows a child select box to change its options dependent on its parent select box.

Demo

Additional options

You can pass in options as a third parameter. The currently supported options are:

  • childOptionIsDependentOnParentOption(childOption, parentOption): Function that determines if the childOptionshould be displayed if parentOption is selected. Default: true if the value of the parent option is a prefix of the value of the child option, else false.
  • resetParentOptionOnEmptyChildOption: Resets the parent option to an empty value if the child option changes to an empty option. Default true.
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.