Bootstrap datetimepicker no action

Asked by At

I am trying to implement the bootstrap datetimepicker and am running into an issue where clicking on the input box doesn't trigger any action. I have double checked my imports along with the code itself following several tutorials, but I am not able to find the issue with my code. The imports I am using are as followed:

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet">
<script src="js/bootstrap-datetimepicker.min.js"></script>

<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

I have downloaded the datetimepicker repo and have selected the css and js folder and moved them to the main directory.

The code I am calling for the label is as follows:

<div class="row">
                                            <div class='col-sm-6'>
                                                <input size="16" type="text" class="form-control" id="datetime" readonly>

                                                <script type="text/javascript">
                                                    $("#datetime").datetimepicker({
                                                        format: 'yyyy-mm-dd hh:ii'
                                                    });
                                                </script>
                                            </div>
                                        </div>

As I have stated the label doesn't have any action when clicked on. I am not sure if you need the whole webpage to understand my issue but I will post it below:

<?php
require('./includes/connection.php');
require('./includes/crypt.php');
require('functions.php');

session_start();
ob_start();

/**
 * Created by PhpStorm.
 * User: peri
 * Date: 2019-04-07
 * Time: 16:48
 */



if(isset($_GET['cancel'])) {
    header('Location: messaging.php');
    exit();
}
if(isset($_GET['confirm'])) {
    if(isset($_GET['reason'])) {
        //Encrypted text
        $encrypted_text = encrypt_text($_GET['reason'], $key, $iv);

    }
}

?>

<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet">
    <script src="js/bootstrap-datetimepicker.min.js"></script>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

    <title>New Appointment</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark align-center">
    <a class="navbar-brand" href="#">EMR System</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse align-center" id="navbarNav">
        <ul class="navbar-nav align-center">
            <li class="nav-item">
                <a class="nav-link" href="#">Home</a>
            </li>
            <li class="nav-item active">
                <a class="nav-link" href="#">Appointment <span class="sr-only">(current)</span></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Prescription</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Lab Tests</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Billing</a>
            </li>
        </ul>
    </div>
    <div class="navbar-collapse collapse order-3 dual-collapse2">
        <ul class="navbar-nav ml-auto">
            <li class="nav-item">
                <a href="#" class="navbar-left"><img src="https://png.pngtree.com/element_our/sm/20180620/sm_5b29c1b6c8772.png" width="45px" height="45px"></a>
            </li>
        </ul>
    </div>
</nav>
<br>
<div class="container h-100">
    <div class="row align-items-center h-100">
        <div class="col-5 mx-auto">
            <div class="card h-100 border-primary justify-content-center">
                <div>
                    <?php
                    //Running query to fetch physician details
                    $row = get_physician_information_messaging($_SESSION['phy_ssn']);
                    //echo var_dump($row);
                    //$message = "test";
                    //insert_message($_SESSION['ssn'], $message, 0);
                    ?>
                    <table class="table">
                        <thead class="thead-dark">
                        <tr>
                            <th scope="col" colspan="6">Physician Information</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <th scope="row">First Name:</th>
                            <td class="col-md-6"> <?php echo $row[0]?></td>
                            <th scope="row">Last Name:</th>
                            <td class="col-md-6"> <?php echo 'Dr. ' . $row[2]?></td>
                        </tr>
                        <tr>
                            <th scope="row">Phone Number:</th>
                            <td class="col-md-6"><?php echo $row[3] ?></td>
                            <th scope="row">Speciality:</th>
                            <td class="col-md-6"><?php echo $row[4] ?></td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<br>
<div class="container h-100">
    <div class="row align-items-center h-100">
        <div class="col-12 mx-auto">
            <div class="card h-100 border-primary justify-content-center">
                <div>
                    <form method="get" action="new_appointment.php">
                        <table class="table">
                            <thead class="thead-dark">
                            <tr>
                                <th scope="col" colspan="2">Reason for visit</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td>
                                    <div class="form-group">
                                        <label for="visit_reason">Enter your reason for the visit. Be as descriptive as possible.</label>
                                        <textarea class="form-control" id="visit_reason" rows="3" name="reason"></textarea>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div class="container">
                                        <div class="row">
                                            <div class='col-sm-6'>
                                                <input size="16" type="text" class="form-control" id="datetime" readonly>

                                                <script type="text/javascript">
                                                    $("#datetime").datetimepicker({
                                                        format: 'yyyy-mm-dd hh:ii'
                                                    });
                                                </script>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td class="text-center">
                                    <button type="submit" class="btn btn-success" name="confirm">Confirm</button>
                                    <button type="submit" class="btn btn-danger" name="cancel">Cancel</button>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>

Could someone point out my issue? (Note: All of the code I have used for the datetimepicker were copied pasted from tutorials which is another reason as to why I am puzzled.)

0 Answers