filteredWith
A jQuery plugin that filters a select element from the selected item of another select element.
Usage
filteredWith matches the optgroup label of a select element with the display text of another select element in order to filter it.
<select name="make_id" id="makes">
<option value="">All Makes</option>
<option value="2">BMW</option>
<option value="2">Chevrolet</option>
</select>
<select name="model_id" id="models">
<option value="">All Models</option>
<optgroup label="BMW">
<option value="116">1-Series</option>
<option value="233">3-Series</option>
</optgroup>
<optgroup label="Chevrolet">
<option value="173">Avalanche</option>
<option value="115">Aveo</option>
</optgroup>
</select>
<script>
$('#models').filteredWith('#makes', subText: 'All Models for Make');
</script>Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
License
Licensed under the MIT License.