Java Script


JavaScript Tutorial


Admission Enquiry Form


How show years in select tag using for loop?

Example :

<html>
<head>
<title>Show years in Drop down list using for loop</title>

</head>
<body>
<label>Select Year:</label>
<script>
var i;
document.write("<select>");
for(i=1991;i<=2040;i++)
{
document.write("<option>"+i+"</option>");
}
document.write("</select>");
</script>
</body>
</html>

Output:

Show years in Drop down list using for loop