Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datalist arrow not coming in ie and firefox

Hi I am using a datalist tag for a dropdown as in the fiddle. I am getting the arrow for dropdown in chrome only. and the arrow is not coming in ie and firefox. In firefox the search is lazy search ie; it is not based on the first letter

The fiddle is:: https://jsfiddle.net/v7fg0zc8/ pleas specify the styling if any to achieve this

  <!DOCTYPE html>
  <html>
  <body>
      <input list="browsers" name="browser">
      <datalist id="browsers">
      <option value="Internet Explorer"></option>
          <option value="Firefox"></option>
          <option value="Chrome"></option>
          <option value="Opera"></option>
          <option value="Safari"></option>
      </datalist>
  </body>
  </html>
like image 665
CharanbabuKarnam Avatar asked Jun 25 '15 05:06

CharanbabuKarnam


People also ask

Is Datalist supported by all browsers?

Unfortunately, Internet Explorer and Chrome are the only browsers to support datalists on range inputs at this time.

What is alternative for Datalist?

Alternatives to <datalist> If you need type-entry autocomplete, the most widely supported solution is Javascript. JQueryUI's autocomplete module is probably the most commonly used option.

Is Datalist tag in HTML5?

The datalist tag is introduced in HTML5. The <datalist> tag should be used with an <input< element that contains a "list" attribute. The value of "list" attribute is linked with the datalist id.

Is the Datalist tag and select Tag same?

Generally, both the tags are used for choosing an option from the given list. But the main difference between both is that in the <datalist> tag the user can enter its own input and add that as an option with the help of the <input> element whereas the <select> tag doesn't provide this feature.


2 Answers

Check with this. I've tried so many ways but not worked well. May be this is the only solution

input::-webkit-calendar-picker-indicator {
  display: none;/* remove default arrow */
}
.myarrow:after {
    content: url(https://i.stack.imgur.com/i9WFO.png);
    margin-left: -20px; 
    padding: .1em;
    pointer-events:none;
}
<span class="myarrow"><input list="browsers" name="browser" id="#show-suggestions"></span>
<datalist id="browsers">
  <option value="Internet Explorer"></option>
  <option value="Firefox"></option>
  <option value="Chrome"></option>
  <option value="Opera"></option>
  <option value="Safari"></option>
</datalist>
like image 51
Jishnu V S Avatar answered Sep 18 '22 02:09

Jishnu V S


Interesting. I tested this on my machine and got the same result :( The drop down arrow only appeared in Chrome, although in FF I could still select from the list but without a drop down arrow.

What if you just used the SELECT tag instead?

<select>
    <option value="Internet Explorer" >Internet Explorer</option>
    <option value="Firefox" >Firefox</option>
    <option value="Chrome" >Chrome</option>
    <option value="Opera" >Opera</option>
    <option value="Safari" >Safari</option>
</select>

I did some more digging on this and found this post... HTML Form: Select-Option vs Datalist-Option

It better explains the difference between datalist and select. That could also be why my suggestion of using SELECT instead might not be appropriate. But it could also explain the lack of the arrow. I don't see anywhere in the other discussions about the arrow being a guaranteed behaviour. The datalist may still function as an auto complete, but without the drop down arrow (although I just checked this again in IE11 and it doesn't even seem to do the autocomplete).

Perhaps this can just get put down to how well different browsers implement this feature.

like image 35
Lucien Stals Avatar answered Sep 22 '22 02:09

Lucien Stals