How to set a default option in select with data-live-search HTML?

3

I need to bring in the select a default option every time the page loads. But with the data-live-search plugin. Is this possible?

    <div class="row-fluid">
  <select class="selectpicker" data-show-subtext="true" data-live-search="true">
    <option data-subtext="Rep California">Tom Foolery</option>
    <option data-subtext="Sen California">Bill Gordon</option>
    <option data-subtext="Sen Massacusetts">Elizabeth Warren</option>
    <option data-subtext="Rep Alabama">Mario Flores</option>
    <option data-subtext="Rep Alaska">Don Young</option>
    <option data-subtext="Rep California" disabled="disabled">Marvin Martinez</option>
  </select>

Itookthisexamplefromthenetwork.IwanteditwhenIwasviewingthepage,thatbydefaultselectwouldbringmeaspecificvalue.Ex:insteadofbringing"Tom Foolery" according to the image, bring "Maickon" for example. Setting the value property is not working.

    
asked by anonymous 25.02.2016 / 13:43

3 answers

0

Well the good thing is always to test possible simple solutions and read the API as much as possible. For you to test future bootstrap plugins visit Bootply .

Following the basic concept that deals with an HTML object use the full attribute to select the option: selected="selected"

See working on exampleSelect I did.

    
09.03.2016 / 15:02
0

Just do it:

<option selected>Minha Opção</option>

Reference: link

    
25.11.2016 / 21:59
-1

Live search unlike SELECT is an INPUT, and it needs to receive what will be searched, and this should not be pre-inserted. Generally the results The right one is to use placeholder="Tim Martin" in the input, to have a text in the background in the input. In your case there, even if you pre-fill the field it should only update after you edit at least one space. The ideal is to have nothing, because it does not work as a dead search field, it is a live search.

    
23.10.2018 / 10:42