I am trying to put in a bootstrap datetimepicker in my customized table. But it just won't work. i understood that you can't placed a script in th, so i placed it in td, but it's still not working.
Simple and working datepicker.
<tr>
<td>Date</td>
<td><!-- mktime(hour, minute, second, month, day, year) -->
<input type="text" name="call_date" value="<?php echo $adjdate;?>" id="datepicker" class="input-small">
</td>
</tr>
When i tried to implement bootstrap date time picker, it just won't work. I think i've misplaced something in the code below here.
<tr>
<td>Date</td>
<td>
<div class="container">
<div class="row">
<div class='col-sm-6'>
<div class="form-group">
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
$('#datetimepicker1').datetimepicker();
});
</script>
</div>
</div>
</td>
</tr>
Additional info: i forgot to mention that i've added in
<script src=".1.1/jquery.min.js"></script>
<script src=".js/2.18.1/moment.min.js"></script>
<script src=".3.7/js/bootstrap.min.js"></script>
<script src=".17.47/js/bootstrap-datetimepicker.min.js"></script>
<link href=".3.7/css/bootstrap.min.css" rel="stylesheet"/>
But if i placed code outside instead of putting inside td, it will work
<div class="container">
<div class="row">
<div class='col-sm-6'>
<div class="form-group">
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
$('#datetimepicker1').datetimepicker();
});
</script>
I just need advice regarding this, and thanks for showing me those examples, it helps a lot, thank you
I am trying to put in a bootstrap datetimepicker in my customized table. But it just won't work. i understood that you can't placed a script in th, so i placed it in td, but it's still not working.
Simple and working datepicker.
<tr>
<td>Date</td>
<td><!-- mktime(hour, minute, second, month, day, year) -->
<input type="text" name="call_date" value="<?php echo $adjdate;?>" id="datepicker" class="input-small">
</td>
</tr>
When i tried to implement bootstrap date time picker, it just won't work. I think i've misplaced something in the code below here.
<tr>
<td>Date</td>
<td>
<div class="container">
<div class="row">
<div class='col-sm-6'>
<div class="form-group">
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
$('#datetimepicker1').datetimepicker();
});
</script>
</div>
</div>
</td>
</tr>
Additional info: i forgot to mention that i've added in
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare./ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<script src="https://maxcdn.bootstrapcdn./bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare./ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
<link href="https://maxcdn.bootstrapcdn./bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
But if i placed code outside instead of putting inside td, it will work
<div class="container">
<div class="row">
<div class='col-sm-6'>
<div class="form-group">
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
$('#datetimepicker1').datetimepicker();
});
</script>
I just need advice regarding this, and thanks for showing me those examples, it helps a lot, thank you
Share Improve this question edited Jun 5, 2017 at 10:41 lye yan nian asked Jun 5, 2017 at 9:50 lye yan nianlye yan nian 1432 silver badges13 bronze badges 2-
Should it be really in a
div
and not in aninput
? – Carl Binalla Commented Jun 5, 2017 at 9:53 - i just tried out the some of the codes in eonasdan.github.io/bootstrap-datetimepicker and tried to apply the codes from there. For my situation, i need the datetimepicker to work in my table. For the example in bootstrap datetimepicker, they put it in div class, you can have a look through the look i attached here. Thank you – lye yan nian Commented Jun 5, 2017 at 9:57
3 Answers
Reset to default 4Load Jquery
,moment.js
before datetimepicker
.
$(function () {
$('#datetimepicker1').datetimepicker();
});
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare./ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<script src="https://maxcdn.bootstrapcdn./bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare./ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
<link href="https://maxcdn.bootstrapcdn./bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<tr>
<td>Date</td>
<td>
<div class="container">
<div class="row">
<div class='col-sm-6'>
<div class="form-group">
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>
</div>
</td>
</tr>
install the package Install-Package Bootstrap.v3.Datetimepicker.CSS
<script>
jQuery(document).ready(function () {
jQuery('.datepicker').datetimepicker({ format: 'DD/MM/YYYY' });
jQuery('.datetimepicker').datetimepicker();
});
</script>
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script> <!-- Bootstrap v3.3.5 -->
<script src="~/Scripts/moment.js"></script>
<script src="~/Scripts/bootstrap-datetimepicker.min.js"></script>
<script src="~/Scripts/Core.js"></script>
<div class="modal-header__training-start">Start at
<input type="text" id="datetimepicker-start" class="datetimepicker-start" data-function="training-start">
<div class="datetimepicker-icon">
<span class="glyphicon glyphicon-calendar" style="top:3px;"></span>
</div>
$("#datetimepicker-start").datetimepicker(
{
format: 'yyyy-mm-dd hh:ii:ss',
});
I think the selector must be the input to start datetimepicker.
You have to include 2 files to project: bootstrap-datetimepicker.js & bootstrap-datetimepicker.css