Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with timepicker

I have used timepicker in my project but its not working properly.It gave me Uncaught Type Error.

When i click on textbox i need such output

I tried using timepicker in this way :

<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/clockpicker/0.0.7/bootstrap-clockpicker.min.css">
<title>TimePicker</title>
</head>
<body>
<div class="container">
  <h2>Time Picker</h2>
  <p>This example of time picker using bootstrap and jquery.</p>
  <form>
    <div class="form-group">
      <label for="starttime">Start Time:</label>
      <input type="text" class="form-control" id="starttime" readonly>
    </div>
    <div class="form-group">
      <label for="endtime">End Time:</label>
      <input type="text" class="form-control" id="endtitme" readonly>
    </div>
  </form>
</div>
<script>
$(".starttime").clockpicker({
  twelvehour: true,
});
$("#endtitme").clockpicker({
  twelvehour: true,
});
</script>
</body>
</html>

Thank you in advance

like image 298
Makwana Prahlad Avatar asked Jul 05 '26 09:07

Makwana Prahlad


1 Answers

You have missing clock js in your code

add clock js and its work and also change .starttime to #starttime because its id in your field not class

<script src="http://weareoutman.github.io/clockpicker/dist/jquery-clockpicker.min.js"></script>

$("#starttime").clockpicker({
  twelvehour: true,
  autoclose: true
});
$("#endtitme").clockpicker({
  twelvehour: true,
  autoclose: true 
});
<html>

<head>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/clockpicker/0.0.7/bootstrap-clockpicker.min.css">
  <script src="http://weareoutman.github.io/clockpicker/dist/jquery-clockpicker.min.js"></script>
  <title>TimePicker</title>
</head>

<body>
  <div class="container">
    <h2>Time Picker</h2>
    <p>This example of time picker using bootstrap and jquery.</p>
    <form>
      <div class="form-group">
        <label for="starttime">Start Time:</label>
        <input type="text" class="form-control" id="starttime" readonly>
      </div>
      <div class="form-group">
        <label for="endtime">End Time:</label>
        <input type="text" class="form-control" id="endtitme" readonly>
      </div>
    </form>
  </div>

</body>

</html>

add autoclose: true in your clockpicker

like image 131
Bhargav Chudasama Avatar answered Jul 07 '26 00:07

Bhargav Chudasama



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!