当前位置:首页 > í?ò3ì?D§£oJSêμ???ˉì?μ?è??ú????±íμ¥

í?ò3ì?D§£oJSêμ???ˉì?μ?è??ú????±íμ¥

点击次数:1104  更新日期:2011-01-05
\n


\n

JSêμ???ˉì?μ?è??ú????±íμ¥,ê1ó?·?·¨:


\n

showDateSelect(“date1″)


\n

???D2?êy?a±íμ¥??selectμ???3?,è?oó?éò?ó?date1.value??è?????μ?è??ú.


\n

<html>
<head>
<title> ?ˉì?μ?è??ú????±íμ¥ </title>
<meta http-equiv=”Content-Type” content=”text/html” charset=”gb2312″>
<script language=”JavaScript”>
<!–
function yearList(num){
var d=new Date();
var t=d.getFullYear();
var yStr=”";
for(var i=t-num;i<=t+num;i++){
yStr=yStr+”<option value=’”+i+(i==t?”‘ selected>”:”‘>”)+i+”</option>”;
}
return yStr;
}
function monthList(){
var d=new Date();
var t=d.getMonth()+1;
mStr=”";
for(var i=1;i<=12;i++){
mStr=mStr+”<option value=’”+i+(i==t?”‘ selected>”:”‘>”)+i+”</option>”;
}
return mStr;
}
function dateList(fName){
var d=new Date();
var t=document.all[fName+"_dd"].value==”"?d.getDate():document.all[fName+"_dd"].value;
d=new Date(document.all[fName+"_yy"].value+”/”+document.all[fName+"_mm"].value+”/1″);
dStr=”";
for(var i=1;i<=31;i++){
d.setDate(i);
if(d.getDate()!=i){break;}
dStr=dStr+”<option value=’”+i+(i==t?”‘ selected>”:”‘>”)+i+”</option>”;
}
document.all[fName+"_dx"].innerHTML=”<select name=’”+fName+”_dd’ onchange=’javascript£osetDateValue(\\”"+fName+”\\”);’>”+dStr+”</select>”;
}
function setDateValue(name){
var dValue=document.all[name+"_yy"].value+”-”+document.all[name+"_mm"].value+”-”+document.all[name+"_dd"].value;
document.all[name].value=dValue;
}
function showDateSelect(name){
document.write(“<select name=’”+name+”_yy’ onchange=’javascript£odateList(\\”"+name+”\\”);setDateValue(\\”"+name+”\\”);’>”+yearList(10)+”</select>”);
document.write(“<select name=’”+name+”_mm’ onchange=’javascript£odateList(\\”"+name+”\\”);setDateValue(\\”"+name+”\\”);’>”+monthList()+”</select>”);
document.write(“<span id=’”+name+”_dx’><select name=’”+name+”_dd’>”+”</select></span>”);
dateList(name);
document.write(“<input type=’hidden’ name=’”+name+”‘ value=”>”);
setDateValue(name);
}
//–>
</script>
</head>


\n

<body>
<center><h3>?ˉì?è??ú????±íμ¥ê?ày</h3></center>
<table align=”center” width=”300″ cellspacing=”1″ cellpadding=”5″ border >
<FORM METHOD=POST ACTION=”" onsubmit=”alert(‘date1:’+this.date1.value+’\\ndate2:’+this.date2.value+’\\ndate3:’+this.date3.value);return false;”>

<tr>
<td>è??ú1: <script language=”JavaScript”>showDateSelect(“date1″);</script></td>
</tr>
<tr>
<td>è??ú2: <script language=”JavaScript”>showDateSelect(“date2″);</script></td>
</tr>
<tr>
<td>è??ú3: <script language=”JavaScript”>showDateSelect(“date3″);</script></td>
</tr>
<tr>
<td><CENTER><INPUT TYPE=”submit” value=”SUBMIT”></CENTER></td>
</tr>
</FORM>
</table>
</body>
</html>


\n

\n