Mastering the Art of Live Search in Drop Down Multi Select

I need to develop a search functionality similar to the one found on . This search should allow users to select options from a dropdown menu or type their own search query, and provide live search results. I attempted to use the jQuery plugin https://www.jqueryscript.net/form/Multiple-Select-UI-jQuery.html to create a list effect, but it only displayed the results in a div container. When I tried using an input field instead, it caused issues with the live search feature.

Is there any other jQuery plugin that can assist me in achieving this goal?

<div class="custom-result-section test" placeholder="Find Your Test" > </div>
<button class="tg-btn" type="submit"><i class="lnr lnr-magnifier"></i></button>

                                         </fieldset>
                                          <div class="div_search_box drop-down" style="display: none;">
                                             <span class="cross remove-icon "><img src="images/remove-icon.png" height="50px" width="50px"></span>

                                             <div class="jquery-multiple-select style="float:left;margin-right:50px;"  >
                                                <ul>
                                                  <?php foreach($featured_test as $faetur){  ?>
                                                       <li  data-test-id="<?php echo $faetur['id']; ?>" ><?php echo $faetur['name']; ?></li>

                                                  <?php } ?>


                                                </ul>
                                             </div>

                                             <div class="jquery-multiple-select " style="float:right;margin-right:30px;">
                                                <ul>

                                                  <?php foreach($labbogy_health_pkg as $faetur){  ?>
                                                       <li data-pkg-id="<?php echo $faetur['id']; ?>"><?php echo $faetur['name']; ?></li>
                                                  <?php } ?>

                                                </ul>
                                             </div>
                                          </div>

script

 $(".custom-result-section").on('click', function(){
         $('.div_search_box').css('display','block');   
    });
     $(".cross").on('click', function(){

        $('.div_search_box').css('display','none');

     });

// added the ability to edit the div content

 $('.custom-result-section').each(function(){
    this.contentEditable = true;
});

Answer №1

Have you considered using a modern framework like Bootstrap for your web development needs? If so, here's an example of how you can create a dropdown menu:

          <li class="dropdown">
              <a href="#" class="btn btn-info dropdown-toggle" data-
              toggle="dropdown" role="button" aria-haspopup="true" aria-
              expanded="false">Discover <span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="#">Tokyo</a></li>
                <li role="separator" class="divider"></li>
                <li><a href="#">London</a></li>
                <li role="separator" class="divider"></li>
                <li><a href="#">Paris</a></li>
                <li role="separator" class="divider"></li>
                <li><a href="#">Rome</a></li>
                <li role="separator" class="divider"></li>
                <li><a href="#">Sydney</a></li>
              </ul>
            </li>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unable to launch React Native project on emulator now

Something seems off with my App as it won't start up on my AS Emulator. Everything was running smoothly yesterday, but today it's not working - possibly due to me moving the npm and npm-cache folders, although they are configured correctly with n ...

Is there a way to send a multi-dimensional array using jQuery ajax?

I am encountering an issue with posting an array as a JavaScript variable {{0,0},{1,1},{2,2}} using JSON.Stringify. Whenever I try to post it, I receive an internal server error 500. Can someone please advise on how I can successfully post and utilize this ...

Continue scrolling for additional information to load

My HTML page is quite lengthy, filled with content within li tags. I am looking for a way to avoid loading all of them at once and instead have the page load approximately 10 li tags when the user scrolls down to read further. The goal is to pre-load 15 li ...

I have been experiencing issues with browserify when trying to use both jquery and jquery-ui

I have created a simple test app to showcase an issue I am facing. You can find the demo on this GitHub repository. In this demonstration, the first step was installing jquery and jquery-ui: npm install --save jquery jquery-ui Then I proceeded to creat ...

What is the best way to connect a fresh post to a different URL in ReactJS and Redux?

Currently, I am working with Redux and ReactJS to develop a discussion platform. One of the key features I am trying to implement is where users can input the title and content of their post, which will then be submitted to create a new post. After submit ...

Displaying various Ajax html responses

The function $('.my-button').click(function(e) is designed to display the output of the MySQL query in display.php, presented in HTML format. While it functions correctly, since each button is looped for every post, the script only works for the ...

Using NGRX Effects to Load Data for a Specific Item in Angular

On my website, there is a page that displays a range of products from the store managed by a reducer called products. When an action PRODUCTS.LOAD_ALL is dispatched, it triggers an API call through an effect and then sends a PRODUCTS.LOAD_ALL_SUCCESS actio ...

Set each item to its original position on the draggable container

I am working on a project where I have categories with lists of contacts. Each contact has user details displayed in a table with input elements. I have made the contacts draggable and the categories droppable. When moving a contact from one category to an ...

Does the modal popup extender change the screen size?

I need help understanding if this behavior is normal. I have a well-designed asp.net site with all content fitting on one page without the need for scrolling. However, when a specific button is clicked to show additional content using modalpopupextender, t ...

Best practices for effectively managing errors within JSON web tokens

I am a novice attempting to manage JWT verification. Within the function below, my goal is for the system to generate a new access token based on the refresh token if the user's access token has expired. import { asyncHandler } from "../utils/asy ...

Getting a pair of `focusin` events upon focusing

My Current Project As I work on my project, I encountered an interesting issue with event listeners and focus handling in different browsers. Specifically, when using jQuery's .on() to register a listener for the focusin event and programmatically se ...

Repeated information in HTML tables

I am currently working with two HTML tables and two sets of JSON data. Initially, I load one table with the tableData which has a default quantity of 0. In my HTML form, there are three buttons - save, load draft, and edit. Upon clicking on load draft, I p ...

Adding a character at the beginning of each loop iteration in a nested array with Vue.js

When working inside a v-for loop, I am attempting to add a character at the beginning of each item in a nested array that may contain multiple items. I have explored various options but have not been successful: :data-filter="addDot(item.buttonFilter ...

Displaying TestNG Reporter information in Gradle-generated HTML test reports

I've been searching high and low for a solution to my problem with no luck, so I'm turning directly to you. Is there any way to display TestNG's Reporter output in Gradle HTML reports? Here's the scenario: I have multiple testNG test m ...

Loop through each element in a JSON array using jQuery's `.each()` method

Above is a snippet of my jQuery function: function fetchData(jsonLink){ $(".scrollable .items").html("<img class='loadGif' src='/sites/all/themes/zen/journeyon/images/ajax-loader.gif' alt='' />"); $.ajaxSetup({ ...

Cut off the initial characters in the URL's hash component

Hey there, I'm currently working on a task that involves removing a specific part of a URL string. Here's the scenario: if (window.location.hash == '#super-super-product') { change.window.location.hash.to.this: #product // this i ...

The backend post request is returning only "undefined" in JavaScript

Hey there, I'm still learning JS so please bear with me. I've been working on incrementing a value in a JSON file within my JS backend app. However, whenever I try to increase the associated value by the key, it ends up creating a new section la ...

Retrieving the <select> value seamlessly without the need to submit or refresh the page

I'm currently experimenting with a cart functionality but facing issues making it work. I am trying to create a shopping cart where I can update the quantity of each product using a drop-down list (<select>) and have the price updated automatica ...

"Code snippets customized for React are not functioning properly in the javascriptreact.json file within Visual Studio Code

I'm looking to incorporate some customized React.js code snippets into my Visual Studio Code setup. I am aware of the two files in VSCode that handle this - javascript.json and javascriptreact.json. Although the snippets work well in javascript.json, ...

Displaying Material UI Styles: A Challenge

Currently working on a website using Material-UI and React. Strangely, the styling applied through Material-UI's Hook API functions perfectly on codesandbox.io but fails to work when running locally. Notably, the border radius feature fails to update ...