1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

jquery datepicker

Posted at

Datepicker Widget wiki

code

   <script>
	//	$( "#datepicker" ).datepicker();
		$("#datepicker").datepicker({
	// The hidden field to receive the date
	altField: "#dateHidden",
	// The format you want
	altFormat: "yy/mm/dd",
	// The format the user actually sees
	dateFormat: "yy/mm/dd",
	onSelect: function (date) {
		$("#check_day").val(date);
		updatePreferentialScheme();

	}<?php
	$executeStr="";
	if(count($disableDateList["disableWeekDayList"])>0){
		
		foreach($disableDateList["disableWeekDayList"] as $key=>$value)
		{
				if($executeStr=="")
				{
					$executeStr="date.getDay() != $value";	
				}
				else
				{
					$executeStr.=" && date.getDay() != $value";	
				}
		}
		}
		if(count($disableDateList["disableDateRangeList"])>0){
		
		foreach($disableDateList["disableDateRangeList"] as $item)
		{
				if($executeStr=="")
				{
					$executeStr="!(date.Format(\"yyyy-MM-dd\")>='".date("Y-m-d",$item[0])."' && date.Format(\"yyyy-MM-dd\")<='".date("Y-m-d",$item[1])."') ";	
				}
				else
				{
					$executeStr.=" && !(date.Format(\"yyyy-MM-dd\")>='".date("Y-m-d",$item[0])."' && date.Format(\"yyyy-MM-dd\")<='".date("Y-m-d",$item[1])."') ";	
				}
		}
		}
		if($executeStr!=""){
		?>,beforeShowDay: function(date){ 
			
			return [<?php echo $executeStr;?>,""];}
	<?php }
	if(count($disableDateList["ableDateRangeList"])>0){
		echo ",";
		$configStr="";
		foreach($disableDateList["ableDateRangeList"] as $item)
		{
			$time1=strtotime(date("Y-m-d",strtotime(date("Y-m-d",$item[0])." -1 month")));
			$time2=strtotime(date("Y-m-d",strtotime(date("Y-m-d",$item[1])." -1 month")));
			$item[0]=$time1;
			$item[1]=$time2;
			?>
				minDate: new Date(<?php echo date("Y",$item[0])?>, <?php echo date("m",$item[0])?>, <?php echo date("d",$item[0])?>),
		 maxDate:new Date(<?php echo date("Y",$item[1])?>, <?php echo date("m",$item[1])?>, <?php echo date("d",$item[1])?>)
			<?php
		}	
		 }?>

});
	  </script>
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?