给一段相类的代码,判断日期有点繁,你得想一下:
<body id="hidden_it">
 给你个例子吧!!! 
<SELECT name=ab onchange="chsel();"> 
  <OPTION value="a">a</OPTION> 
  <OPTION value="b">b</OPTION> 
</SELECT> 
<SELECT name=ab2> 
</SELECT> <script language="javascript"> 
var selects=new Array(
  new Array(
    new Option("a1","a1"),
    new Option("a2","a2"),
    new Option("a3","a3")),
  new Array(
    new Option("b1","b1"),
    new Option("b2","b2"),
    new Option("b3","b3")));
function chsel()
{
  ab2.options.length=0;
  if(ab.value=="a")
    k=0;
  if(ab.value=="b")
    k=1;
  for(var i=0;i<selects[k].length;i++)
    ab2.add(selects[k][i]);
}      
function InsertSle(val1,val2,sle) 

var newsle=new Option(val1,val2); 
sle.add(newsle); 

function DelSle(sle,indexsle) 

sle.options[indexsle]=null; 

function DelAndIn(sle1,sle2) 

for(i=0;i<sle1.length;i++) 
if(sle1.options[i].selected){ 
InsertSle(sle1.options[i].text,sle1.options[i].value,sle2); 
DelSle(sle1,i); 


function MoveAll(sle1,sle2) 

var i=sle1.length-1; 
for(;i>=0;i--) 

InsertSle(sle1.options[i].text,sle1.options[i].value,sle2); 
DelSle(sle1,i); 


//MoveAll(prov,city);
//prov.size=1;
</script>
</body>

解决方案 »

  1.   

    <script>
    function getDays(year,month){
    d=new Date();
    d.setFullYear(year,month,31);
    // alert(d.getDate());
    if (d.getDate()<31) return 31-d.getDate();
    return d.getDate();
    }
    function chgDays(){
    yy=document.all.YY.value;
    mm=document.all.MM.value;
    mm--;
    days=getDays(yy,mm);

    olddays=document.all.DD.options.length;
    while (days>olddays){
        olddays++;
    document.all.DD.options.add(new Option(olddays+"日",olddays));
    }
    while (days<olddays){
        olddays--;
        document.all.DD.options.remove(olddays);
    }}
    </script>
    <select size="1" name="YY" onchange=chgDays()>
    <script>
    d=new Date();
    yy=d.getFullYear();
    for (i=0;i<20;i++){
    x=yy-i;
    document.write ("<option value='"+x+"'>"+x+"年</option>");
    }
    </script>
    </select><select size="1" name="MM" onchange=chgDays()>
    <script>
    for (i=1;i<=12;i++){
    document.write ("<option value='"+i+"'>"+i+"月</option>");
    }
    </script>
    </select>
    <select size="1" name="DD">
    <script>
    mm=d.getMonth();
    document.all.MM.selectedIndex=mm;
    dd=d.getDate();for (i=1;i<=30;i++){
    if (i==dd) sel=" selected"
    else sel=""
    document.write ("<option value='"+i+"'"+sel+">"+i+"日</option>");
    }
    </script>
    </select>
      

  2.   

    从年到秒都来啦
    <html>
    <head>
    <title>选择日期</title>
    <style type="text/css">
    <!--
    a:link {text-decoration: none }
    a:visited {text-decoration: none}
    -->
    </style>
    </head>
    <body bgcolor="#EFEFDE"><CENTER><BR>
    <FONT SIZE="4">选择时间</FONT><BR><BR>
    <script>
    var now=new Date();
    var year=now.getYear();
    var month=now.getMonth();
    var day=now.getDate();
    month++;
    document.write("<table><tr><td><select id=selYear onchange=checkDate() >");
    for (tmp=1990;tmp<2010;tmp++)
    document.write("<option value='"+tmp+"'>"+tmp+"</option>");
    document.write("</select>年</td>");document.write("<td><select id=selMonth onchange=checkDate()>");
    for (tmp=1;tmp<13;tmp++)
    document.write("<option value='"+tmp+"'>"+tmp+"</option>");
    document.write("</select>月</td>");document.write("<td id='tdDate'><select id=selDate onchange=checkDate() style='width:50'><option value=1>1</option>");
    document.write("</select>日</td></tr>");
    document.write("<tr height=20><td> </td></tr>");document.write("<tr><td><select id=selHour style='width:55'>");
    for (var i=0;i<24;i++)
    document.write("<option value="+i+">"+i+"</option>");
    document.write("</select>时</td>");
    document.write("<td><select id=selMin style='width:55'>");
    for (var i=0;i<60;i++)
    document.write("<option value="+i+">"+i+"</option>");
    document.write("</select>分</td>");
    document.write("<td><select id=selSnd style='width:55'>");
    for (var i=0;i<60;i++)
    document.write("<option value="+i+">"+i+"</option>");
    document.write("</select>秒</td></tr></table>");document.write("<table >");window.selYear.value=year;
    window.selMonth.value=month;
    checkDate();
    function checkDate()
    {
    //每次改变了年、月时生成新的月历
    tmpyear=window.selYear.value;
    tmpmonth= window.selMonth.value;
    tmpdate=new Date(tmpyear,tmpmonth-1,1);
    tmpday = tmpdate.getDay();//判断第一天是星期几
    tmpday2=new Date(tmpyear,tmpmonth,1).getDay();//判断下个月第一天是星期几
    var tmpstr ="<select id=selDate  style='width:50'>";
    for (tmp=1;tmp<33;tmp++)
    {
    if ( tmp>27 && new Date(tmpyear,tmpmonth-1,tmp).getDay()==tmpday2)//判断是否已经到了下个月
    tmp=34
    else
    {
    tmpstr+="<option value="+tmp+">"+tmp+"</option>";
    }
    }
    tmpstr+="</select>日";tdDate.innerHTML=tmpstr;}
    function selectdate(tmp)
    {
    window.dayField.innerText=tmp;
    }function selectTime()
    {
    //tmpstr=window.selYear.value+"年"+ window.selMonth.value + "月"+window.selDate.value+"日"+window.selHour.value+"时"+ window.selMin.value + "分"+ window.selSnd.value + "秒";
    tmpstr=window.selYear.value+"-"+ window.selMonth.value + "-"+window.selDate.value+"/"+window.selHour.value+"-"+ window.selMin.value + "-"+ window.selSnd.value;
        dialogArguments.selectTime(tmpstr,dialogArguments.event.srcElement);
        window.close();
    }
    function overDate(tmp)
    {
    tmp2 = window.selMonth.value -1;
    if (tmp2 < 10) tmp2 = "0"+tmp2;
    tmpstr=window.selYear.value+tmp2+tmp;
    window.tmpdiv.innerHTML = time(tmpstr);
    }
    </script>
    <BR><BR>
    <button onclick="selectTime()">确定</button>&nbsp;&nbsp;&nbsp;
    <button onclick="window.close()">取消</button>
    </CENTER>
    </body>
    </html>
      

  3.   

    对了,调用他的示范代码:
    <html>
    <head>
    <title></title>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function selectTime(t)
    {
    window.timeInput.value=t;
    }
    //-->
    </SCRIPT>
    </head>
    <body>
    <input id=timeInput>
     <input type="button" name="Submit45"value="选择时间"onClick="showModalDialog('timeSelecter.html',window)">
    </body>
    </html>
      

  4.   

    <select id=year onchange=toDay()>
    <option value=2000>2000</option>
    <option value=2001>2001</option>
    <option value=2002>2002</option>
    </select>
    <select id=month onchange=toDay()>
    <option value=0>1</option>
    <option value=1>2</option>
    <option value=2>3</option>
    <option value=3>4</option>
    <option value=4>5</option>
    <option value=5>6</option>
    <option value=6>7</option>
    <option value=7>8</option>
    <option value=8>9</option>
    <option value=9>10</option>
    <option value=10>11</option>
    <option value=11>12</option>
    </select>
    <select id=day></select><script>
    function toDay(){
    vYear=parseInt(document.all.year.options[document.all.year.selectedIndex].value)
    vMonth=parseInt(document.all.month.options[document.all.month.selectedIndex].value)
    day.length=0;
    while((d=new Date(vYear,vMonth,day.length+1)).getMonth()==vMonth){day.options[day.length++].value=day.length;day.options[day.length-1].text=day.length;}
    }
    window.onload=toDay
    </script>
      

  5.   

    如果搁在form中
    对应的day改为document.all.day
      

  6.   

    qiushuiwuhen(秋水无恨) 的代码写的比我的精彩,才给5分?你不会是看代码长度给分的吧?