Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
294 views
in Technique[技术] by (71.8m points)

php - Jquery dynamic Nested or Multi-level dropdown, options change for same field when selected

I need a feature for a dropdown that's a cross between chained fields and navigation for select field options. The idea is the dropdown loads options from Ajax/php, when the user selects an option, the options change with a link as the first option to return to the previous set of options.

I want to use Jquery, Bootstrap 4, Select2 .. although Select2 may not be needed but I like the search options tool

All is happening in one field, dynamically loading new options

Example:
Select Product
Windows       |--- Back to Products   |---  Back to Products
Doors---------|    Wood Doors         |     Back to Doors
Glass              Vinyl Doors--------|     Vinyl Entry
                                            Vinyl Sliders

enter image description here

<div class="btn-group">
  <button type="button" class="btn btn-danger dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">Action</button>
   <ul class="dropdown-menu">
     <li><a class="dropdown-item" href="#">Action</a></li>
     <li><a class="dropdown-item" href="#">Another action</a></li>
     <li><a class="dropdown-item" href="#">Something else here</a></li>
     <li><hr class="dropdown-divider"></li>
     <li><a class="dropdown-item" href="#">Separated link</a></li>
  </ul>
$(document).ready(function(){ var load_action = 'getNextList'; $.ajax({ url:"action.php", method:"POST", data:{load_action:load_action}, success:function(data){ /* Replace options? make sure link is included in source?? */ } }); }); question from:https://stackoverflow.com/questions/65944893/jquery-dynamic-nested-or-multi-level-dropdown-options-change-for-same-field-whe

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I didn't know exactly what to call it, I searched "nested" and "Multi-level".
I did finally stumble on a few plugins, hope this helps someone else:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...