这是一个日期连动的下接菜单,你可仿照方法改一下。
<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>

解决方案 »

  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.   

    <p><select size="1" name="sel1" onchange="document.all.sel2.options[this.value-1].selectedIndex=true">
      <option value="1">aaaaaa</option>
      <option value="2">bbbbbbbb</option>
      <option value="3">cccccccc</option>
    </select><select size="1" name="sel2">
      <option value="xxxxxxx">xxxxxxx</option>
      <option value="yyyyyyy">yyyyyyy</option>
      <option value="zzzzzzzzz">zzzzzzzzz</option>
    </select></p>
      

  3.   

    <html>
    <HEAD>
    <title>例子</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"><SCRIPT LANGUAGE="JavaScript">
    var meng1Array =  new Array("('选择Heha.net栏目内容','',true,true)",
    "('学习 XML')",
    "('学习 Javascript')",
    "('学习 PHP')");
    var mengArray =  new Array("('选择Myrice.com栏目内容','',true,true)",
    "('学习 Flash')",
    "('学习 Dreamweaver Ultradev')",
    "('学习 Java')");
    var meng2Array =  new Array("('选择China.com栏目内容','',true,true)",
    "('查找歌词')",
    "('其他')");function populatemxhweb(inForm,selected) {
    var selectedArray = eval(selected + "Array");
    while (selectedArray.length < inForm.mxhweb.options.length) {
    inForm.mxhweb.options[(inForm.mxhweb.options.length - 1)] = null;
    }
    for (var i=0; i < selectedArray.length; i++) {
    eval("inForm.mxhweb.options[i]=" + "new Option" + selectedArray[i]);
    }inForm.mxhweb.options[2].selected=true}</script></head><body topmargin="0" leftmargin="0" marginweight="0" marginheight="0"  bgcolor="#0099FF" oncontextmenu="return false;"><p>&nbsp;</p>
    <font color="#000066">说明:适用于IE4,IE5.5,IE5,NS4+,NS6。早期版本的IE5.0可能无法工作。</font> 
    <center>
    <form name="globe">
    <table width="80%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td>
    <select  onChange="populatemxhweb(document.globe,this.options[selectedIndex].value)">
    <option>请选择
    <option value="meng">http://lucky.myrice.com
    <option value="meng1">http://go.163.com/colorweb
    <option value="meng2">http://egirl.51.net
    </select>
    </td>
    <td>
    <select name="mxhweb" onChange="window.open('http://egirl.51.net')">
    <option value=''>☆ 请选择上面的选项 ☆</option>
    </select>
    </td>
    </tr>
    </table></form>
    </center>
    </body>
    </html>