Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<p>Click the button to create an INPUT field, a DATALIST element and an OPTION element.</p>
<form id="myForm">
</form>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
  var x = document.createElement("INPUT");
  x.setAttribute("list", "browsers");
  document.getElementById("myForm").appendChild(x);
  var y = document.createElement("DATALIST");
  y.setAttribute("id", "browsers");
  document.getElementById("myForm").appendChild(y);
  var z = document.createElement("OPTION");
  z.setAttribute("value", "Chrome");
  document.getElementById("browsers").appendChild(z);
}
</script>
</body>
</html>