GithubHelp home page GithubHelp logo

deirvlon / select-relations Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 30 KB

The "select-relations" library is a lightweight JavaScript tool that dynamically filters options in HTML select elements based on selected values of related select elements, offering efficient multi-parent support and built-in reset functionality.

Home Page: https://deirvlon.com

HTML 28.70% JavaScript 71.30%
html html-select js select select2 select2-sort selection-sort

select-relations's Introduction

Select Relations JS

Select Relations JS is a lightweight JavaScript library designed to simplify the process of filtering options in HTML select elements based on the selected values of other related select elements.

Features

  • Dynamic Filtering: Automatically filters options in select elements based on the selected values of other related select elements.
  • Multi-Parent Support: Supports scenarios where a select element's options depend on the selected values of multiple parent select elements.
  • Efficient Implementation: Optimized code ensures efficient filtering and minimal impact on page performance.
  • Reset Functionality: Provides built-in functionality to reset the selection of parent select elements if the selected option becomes hidden due to filtering.
  • Easy Integration: Simple and intuitive API allows for easy integration into existing projects with minimal setup.

Usage

<div class="container">
  <select id="countrySelect" class="select-relations">
    <option value="USA">USA</option>
    <option value="Canada">Canada</option>
  </select>
  <select id="citySelect" class="select-relations" data-sf-parent="countrySelect">
    <option value="New York" data-pr="countrySelect:USA">New York</option>
    <option value="Los Angeles" data-pr="countrySelect:USA">Los Angeles</option>
    <option value="Toronto" data-pr="countrySelect:Canada">Toronto</option>
    <option value="Vancouver" data-pr="countrySelect:Canada">Vancouver</option>
  </select>
  <select id="regionSelect" class="select-relations" data-sf-parent="citySelect">
    <option value="Manhattan" data-pr="citySelect:New York">Manhattan</option>
    <option value="Brooklyn" data-pr="citySelect:New York">Brooklyn</option>
    <option value="Hollywood" data-pr="citySelect:Los Angeles">Hollywood</option>
    <option value="Downtown" data-pr="citySelect:Los Angeles,citySelect:Toronto">Downtown</option>
    <option value="North Vancouver" data-pr="citySelect:Vancouver">North Vancouver</option>
    <option value="West Vancouver" data-pr="citySelect:Vancouver">West Vancouver</option>
  </select>
</div>


<!-- Select Relations JS -->
<script src="select-relations.js"></script>

License

Select Relations JS is released under the MIT License.

select-relations's People

Contributors

deirvlon avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.