Right. I’m trying to add <option> elements to a <select> list. It isn’t going too well! The option elements are years from 2004-2013. My code below successfully increments my year variable, but I’m obviously going awry with how I’m writing to the document. At the moment I get 10 separate select boxes instead of the single select list containing the 10 options for each year. If someone could point me in the right direction to resolve I’d be very grateful.
Code:
<body>
<script language="JavaScript">
<!-- start JS code hide
// loop to create the list
var year = 2003
for (var i=1; i <=10; i++)
{
year++;
document.write("<select name='years'>");
document.write("<option>" + year + "</option>");
}
// end JS code hide -->
</script>
<form name="yearform">
</select>
</form>
</body>