Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap datepicker date-range not showing on calander

I implemented bootstrap datepicker date-range in the below snippet but I don't see the range showing on the calendar after I have selected a date for start date and end date.

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet"
	href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script
	src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<script
	src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<link rel="stylesheet" type="text/css"
	href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker.standalone.min.css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Page 2</title>

</head>
<body>
	<div class="input-group input-daterange">
		<input id="startDate1" name="startDate1" type="text"
			class="form-control" readonly="readonly"> <span
			class="input-group-addon"> <span
			class="glyphicon glyphicon-calendar"></span>
		</span> <span class="input-group-addon">to</span> <input id="endDate1"
			name="endDate1" type="text" class="form-control" readonly="readonly">
		<span class="input-group-addon"> <span
			class="glyphicon glyphicon-calendar"></span>
		</span>
	</div>

	<script
		src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			$('.input-daterange input').each(function() {
				$(this).datepicker();
			});
		});
	</script>
</body>
</html>
like image 946
user3429531 Avatar asked Dec 31 '16 12:12

user3429531


1 Answers

you need to add the bootstrap-datepicker css resource as well.

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker.min.css" />

and use the below syntax for date range.

 $('.input-daterange').datepicker({});

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet"
	href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker.min.css" />
  <script     
	src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<script
	src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<link rel="stylesheet" type="text/css"
	href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker.standalone.min.css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Page 2</title>

</head>
<body>
	<div class="input-group input-daterange">
		<input id="startDate1" name="startDate1" type="text"
			class="form-control" readonly="readonly"> <span
			class="input-group-addon"> <span
			class="glyphicon glyphicon-calendar"></span>
		</span> <span class="input-group-addon">to</span> <input id="endDate1"
			name="endDate1" type="text" class="form-control" readonly="readonly">
		<span class="input-group-addon"> <span
			class="glyphicon glyphicon-calendar"></span>
		</span>
	</div>

	<script
		src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			 $('.input-daterange').datepicker({
              });
		});
	</script>
</body>
</html>
like image 183
Deep Avatar answered Sep 28 '22 07:09

Deep