0

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> 

我怎樣才能添加佔位符的選擇框是輸入文本。該文本框是動態生成的。我研究了這個,但無法找到任何有用的內容。請幫助我。

例如:參考此鏈接 https://silviomoreto.github.io/bootstrap-select/examples/#live-search

+0

這是你要搜索的內容? http://stackoverflow.com/questions/5805059/how-do-i-make-a-placeholder-for-a-select-box – Roman

+0

不,我經歷過,但在我的情況下,有可編輯的文本框。 @Roman – Mohammed

+0

您的代碼與您發佈的鏈接的示例相同嗎? – Roman

回答

2

試試這個從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> 
+0

我試過這個,但是不工作。@ RemyaJ – Mohammed

+0

你能試試嗎? – RemyaJ

+0

Working.Great。謝謝曼@RemyaJ – Mohammed

0

能否請您添加數據實時搜索佔位符=「示例」屬性附加傷害,的元素?

+0

不工作。 @YakyRafael – Mohammed

+0

@Mohammed你可以在這裏添加你的代碼嗎? –

+0

已更新。檢查@YakyRafael – Mohammed

1

確定。 我有你的解決方案。 請下列選項添加到jQuery函數調用:

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

我做了一個CodePen live example here ..

相關問題