2015-12-04 45 views
0

我有一个经典的ASP系统jQuery日期选择器,我想要自动禁用一些日子。此日期将自动填充禁用日期的数组。 (今天是使用该功能的手动)调用与日期列表禁用jQuery日期选择器的日期列表

var disableddates = ["10-12-2015", "11-20-2015", "12-21-2015", "12-22-2015", "12-23-2015", "12-24-2015", "12-25-2015", "12-28-2015", "12-29-2015", "12-30-2015", "12-31-2015", "1-1-2016"]; 

我有一个SQL Server过程给我一个所有这些日期的列表。 如何在打开日期选择器并禁用所有这些日期之前调用它?

+0

我不明白这个问题。你问如何将这些日期传递给sql,或者你问如何禁用收到的日期或其他东西? –

+0

我有这个日期在SQL上我需要通过这个日期做datepicker来禁用这个。 – user2046486

+0

[JQuery UI日期选择器可能重复。禁用数组日期](http://stackoverflow.com/questions/15400775/jquery-ui-datepicker-disable-array-of-dates) –

回答

0

另一个问题的答案中的示例不是手动(或动态)的;它只是没有显示所有前面的步骤。基本上,你想要的是用VBScript编写JavaScript,或者换句话说,用服务器端代码编写你的客户端代码。当然,如果你仔细想想,你总是使用服务器端代码来编写你的客户端代码,但它并不总是那么明显。

<% 
dim ForbidDates, sql, rs 
'... 
'... add code here to call the SQL Server procedure & put the results into a recordset... 
'... 
ForbidDates = rs.GetString(,,"','","'",) 
'- you may need code to clean up the beginning/end of ForbidDates, 
'- e.g. removing any extraneous commas from the end, making sure 
'- the first value has quotes around it correctly, etc. 
'... 
%> 
<script type="text/javascript"> 
var array = [<%=ForbidDates%>] 
$('input').datepicker({ 
    beforeShowDay: function(date){ 
     var string = jQuery.datepicker.formatDate('yy-mm-dd', date); 
     return [ array.indexOf(string) == -1 ] 
    } 
}); 
</script> 
0

我调用的过程beore,并通过了结果给一个变量: VAR disableddates = <%= vardatasfim%>

可变disableddates是在该禁用周末和被调用的函数使用的beforeShowDay

相关问题