2

enter image description here

 <select   class="form-control selectpicker" id="specialty_id" data-live-search="true"  tabindex="-98" name="specialty_id" >

                                <option selected="" value="0" id="ee" <?php if(isset($_GET['sp_id']) && $_GET['sp_id'] == 0): ?>{{ 'selected="selected"' }} <?php endif; ?>>Choose a Sp</option>
                                  @foreach($searchdropdown['dsp'] as $dsptext)
                                    <option value="{{ $dsptext->spect }}" <?php if(isset($_GET['sp_id']) && $_GET['sp_id'] == $dsptext->spect): ?>{{ 'selected="selected"' }} <?php endif; ?>>{{ $spdata->sp }}</option>

                                  @endforeach

                              </select>

How can I add placeholder to that input text in selectbox. That textbox is generated dynamically. I researched about this but unable to found any helpful content. Please help me for this.

for example : Refer this link https://silviomoreto.github.io/bootstrap-select/examples/#live-search

Mohammed
  • 319
  • 1
  • 3
  • 15

5 Answers5

9

Try this from https://github.com/silviomoreto/bootstrap-select/blob/master/test.html,

<select class="selectpicker" multiple data-live-search="true" data-live-search-placeholder="Search" data-actions-box="true">
            <optgroup label="filter1">
              <option>option1</option>
              <option>option2</option>
              <option>option3</option>
              <option>option4</option>
            </optgroup>
            <optgroup label="filter2">
              <option>option1</option>
              <option>option2</option>
              <option>option3</option>
              <option>option4</option>
            </optgroup>
            <optgroup label="filter3">
              <option>option1</option>
              <option>option2</option>
              <option>option3</option>
              <option>option4</option>
            </optgroup>
          </select>
RemyaJ
  • 5,358
  • 4
  • 22
  • 41
1

Ok. I have a solution for you. Please add the following option to the Jquery function call :

$('.selectpicker').selectpicker(
  {  
    liveSearchPlaceholder: 'Placeholder text'
  }
);

I made a CodePen live example here..

Yaky Refael
  • 166
  • 1
  • 8
  • FWIW, this works as a data attribute on the ` – Ben Y Aug 17 '22 at 02:18
0

Can you please add data-live-search-placeholder="Example" atribute, to the element ?

Mohammed
  • 319
  • 1
  • 3
  • 15
Yaky Refael
  • 166
  • 1
  • 8
0

For your whole project, you can use jquery code.

    $(document).ready(function(){

      //selectpicker search placeholder
      $('.bs-searchbox input').attr('placeholder', 
      'Search record..');
     });
Muhammad Adnan
  • 396
  • 3
  • 10
0

Just simply add this data-title attribute in select tag

data-title="Search Here"

eg.

<select class="selectpicker" data-live-search="true" data-title="Search Here">
    <option>ABC</option>
    <option>DEF</option>
    <option>GHI</option>
</select>
Vinod Selvin
  • 369
  • 2
  • 10