I am attempting to populate a datalist via javascript, but failing miserably. The code below looks ok (to me) - but obviously is not.
I need the datalist to be populated off an array and eventually embeded within PHP echo
<html>
<head>
<script type="text/javascript">
function populate()
{
var cars = ["Saab", "Volvo", "BMW"];
var counter=0;
for (counter=0; counter<cars.length; counter++)
{
options +='<option value='+cars[counter]+'/>';
document.getElementById('mylist').innerHTML = options;
}
}
</script>
</head>
<body>
<input list="mylist" />
<datalist id="mylist">
<option value="address1">
<option value="address2">
</datalist>
<input type="button" onclick="populate();" >
</body>
</html>