Need help with JavaScript form select options
Hi all,
I'm trying to create a simple form selection using a JavaScript loop and it is not displaying on the page. The span tag by itself will display the items however when I put it inside of the select tag it does not display. I'm not sure exactly what's wrong and could use any assistance.
Thanks Dave
<form>
<select>
<span id="demo5"></span>
<option value="123">123</option>
<option value="456">456</option>
</select>
</form>
<script>
var cars = ["BMW", "Volvo", "Saab", "Ford", "Fiat", "Audi"];
var text = "";
var i;
for (i = 0; i < cars.length; i++) {
text += "<option value=\"" + cars + "\">" + cars + "</option>";
}
document.getElementById("demo5").innerHTML = text;
</script>
