如何在表单提交后使用经典ASP在日期选择器中设置/粘贴日期?

时间:2016-03-22 16:01:28

标签: javascript jquery forms asp-classic datepicker

正如我的标题所解释的那样,我试图通过点击“搜索”按钮提交或设置日期选择器的日期。我尝试在脚本部分下执行此操作,但它不起作用。一旦点击搜索按钮并提交表单,它既不会出现任何错误也不会提供日期。我研究了它,但找不到它的解决方案。非常感谢任何帮助。

<script>
    $(function() {
        $( ".datepicker" ).datepicker();            
    });
    $(document).ready(function () {
    $('input[type=text][id*=startDate]').datepicker({
            showOn: "button",
            buttonImage: "/Images/cal.gif",
            buttonImageOnly: true,
            onSelect: function (dateText, inst) {    $('#HiddenField1').val(dateText) },
            changeMonth: true,
            changeYear: true,
            showWeek: true,
            firstDay: 1

        });
        var theDate;

        if ($('#HiddenField1').val() != "" && $('#HiddenField1').val() != null) {
            theDate = $('#HiddenField1').val();
        }
        else {
            theDate = new Date();
        }
        console.log (theDate);
       // alert(theDate);
        $('input[type=text][id*=startDate]').datepicker("option", "showAnim", 'bounce');
        $('input[type=text][id*=startDate]').datepicker("option", "dateFormat", 'mm/dd/yy');
        $('input[type=text][id*=startDate]').datepicker("option", "altFormat", 'mm/dd/yy');
        $('input[type=text][id*=startDate]').datepicker('setDate', theDate);    
});
</script>
<div id="data">
    <table>
        <form method=get action="<%=request("script_name")%>">
            <tr>
                <td><b><font>Start Date: </td>
                <td><input class="datepicker" id= "startDate" name="startDate" type="text"></td>
                <td><input type="hidden" id= "HiddenField1" name="HiddenField1" type="text"></td> 
                <td><b><font>End Date: </td>
                <td><input class="datepicker" id= "endDate" name="endDate" type="text"></td>
            </tr>
            <tr>
                <td style= "padding:10px;" colspan=4 align=center>
                    <input type=hidden name=action value=OrderDate>
                    <input type=submit value=Search>
                </td>
            </tr>
        </form>
    </table>
</div>

0 个答案:

没有答案