jQuery Generate Years Dropdown Dynamically using JavaScript

Here i’ll justify a way to use jQuery to come up with years dropdown dynamically in JavaScript or JavaScript generate years dropdown dynamically.

<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Generate years for dropdown using jQuery</title>
<script type=”text/javascript” src=”http://code.jquery.com/jquery-1.8.2.js”></script>
<script type=”text/javascript”>
$(function()
{
var noofyears = 100; // Change whatever you want to
var thisYear = (new
Date()).getFullYear();
for (var i = 0; i <=
noofyears; i++) {
var year = thisYear – i;
$(‘<option>’,
{ value: year, text: year }).appendTo(“#ddlyear”);
}
});
</script>
</head>
<body>
<form id=”form1″>
<div>
<select id=”ddlyear”></select>
</div>
</form>
</body>

</html>

Share Your Comments
Previous iWatch it could be huge
Next Microsoft wants to love his Pro Surface 3 users MacBook Air

About author

Aamir Shaikh
Aamir Shaikh 1705 posts

<p>A Blogger, SEO Analyst and passionate Web Developer from India.<br /> Believes in hard work and continues working to achieve success.</p>

View all posts by this author →

You might also like