3

Hello I'm searching for a solution that open the option list of a datalist by click on a button.

<input value="" list="default">
<i class="fa fa-caret-down innerinput" onclick="showList();"></i>

<datalist id="default">
  <option value="Internet Explorer">
  <option value="Firefox">
  <option value="Chrome">
  <option value="Opera">
  <option value="Safari">
</datalist>

Please refer to this fiddle link: http://jsfiddle.net/3zpco1xe/1/

[input][icon] -> icon show datalist options (function if you click into the input field)

Any solution for this?

1
  • The general idea to achieve this is we can programmtically(manually) trigger the HTML focus event or key up event on that input element that associates with that datalist. Here is a robust solution. Trigger html5 input datalist dropdown to show up Commented Oct 20, 2018 at 17:23

3 Answers 3

1

Unfortunately there is no way to do that.

Sign up to request clarification or add additional context in comments.

Comments

-1

Please Click on the icon to show the list. Hope this will help you.

function showList(v)
{  
    document.getElementById('dd').value='';
}
<input value="" list="default" id="dd" onclick="showList(this.value)">


<datalist id="default">
  <option value="Internet Explorer">
  <option value="Firefox">
  <option value="Chrome">
  <option value="Opera">
  <option value="Safari">
</datalist>

Comments

-3

try this

function showList(){
    cat = document.getElementById("default");
    cat.style.display = "block";
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.