---
title: "js select year month"
author: "ootabc"
date: "2014-11-03T21:56:17Z"
tags: []
categories: ["Web前端"]
slug: "js-select-year-month"
draft: false
lastmod: "2014-11-03T21:56:17Z"
id: 2152052
url: "https://ootabc.iteye.com/blog/2152052"
---

<div class="iteye-blog-content-contain" style="font-size: 14px"></div>
```java

<html>
<body>
<select name="F_Period"> 
 
<script>
		var  isdate= new Date(); 
	    var year=isdate.getFullYear();//获取当前年
	    var month=isdate.getMonth()+1;//获取当前月
		for(var i=1;i<13;i++){
		if(month==0){
			year--;
			month=12;
		}
		document.write("<option value=''>"+year+monthHandler(month));
		month--;
	function monthHandler(v_month){
		return v_month<10?'0'+v_month:''+v_month;  
	}
}
 
   
 
</script>
 
</select> 
 
</body>

```