how to apply search for my html select

RAVI 1,076 Reputation points
2022-10-14T07:25:18.827+00:00

Hello

I'm using this code i want search for this select html control how to do so

<script type="text/javascript">

 $(document).ready(function() {  
$('#list').DataTable( {  
    initComplete: function () {  
        this.api().columns("3").every( function () {  
            var column = this;  
            var select = $('<select><option value=""></option></select>')  
                .appendTo( $("#role_menu_placeholder").empty() )  
                .on( 'change', function () {  
                    var val = $.fn.dataTable.util.escapeRegex(  
                        $(this).val()  
                    );  
 
                    column  
                        .search( val ? '^'+val+'$' : '', true, false )  
                        .draw();  
                } );  
 
            column.data().unique().sort().each( function ( d, j ) {  
                select.append( '<option value="'+d+'">'+d+'</option>' )  
            } );  
        } );  

i need like this design

250250-filter.jpg
help me on my code
thanking you

Developer technologies ASP.NET Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2022-10-14T16:18:47.723+00:00

    the browser does not have this feature. as you are using jquery, you will need to write a plugin or pick one with the desired features, try:

    https://select2.org

    0 comments No comments

  2. QiYou-MSFT 4,326 Reputation points Microsoft External Staff
    2022-10-17T07:05:14.02+00:00

    Hi @RAVI ,
    I think you need to provide more code to implement functionality on top of your code.
    You can refer to the following methods:

    <label for="choice">Search: <input list="choice" name="choice" type="text">  
    </label>  
    <datalist id="choice">  
      <option value="Choose">Choose</option>  
      <option value="option">option</option>  
      <option value="Hosp1">Hosp1</option>  
      <option value="Hosp2">Hosp2</option>  
      <option value="Hosp2">Hosp3</option>  
    </datalist>  
    

    250935-%E5%9B%BE%E7%89%871.png

    250917-%E5%9B%BE%E7%89%872.png

    Best regards,
    Qi You


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.