bootstrap datetimepicker not working in DIV class

Viewed 4396

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.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/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

3 Answers
Related