用JS来返回第几周的日期

<asp:DropDownList ID="DropDownList1" runat="server" onchange="addOption()">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server" onchange="getOption()">
</asp:DropDownList>

function addOption() {
        var obj1 = document.getElementById('DropDownList1');
        var index = obj1.selectedIndex; 
         var val = obj1.options[index].value;

        var obj = document.getElementById('DropDownList2');
        obj.options.length = 0;
        for (var i = 1; i < 53; i++) {
            obj.options.add(new Option("第" + i + "周", setOptionDate(val, i)));
        }
    }
   function setOptionDate(y, w)
    {
        return new Date(y, 0, (w - 1) * 7 + 1).toLocaleDateString();
   }
   function getOption() {
       var obj1 = document.getElementById('DropDownList2');
       var index = obj1.selectedIndex; 
        var val = obj1.options[index].value;
       alert(val);
   }

然后在获取日期那个JS函数里面 给一个HiddenField赋值,后台取出来就行了。

你可能感兴趣的:(Date,function,server,asp)