Time picker setting value via query or JS


Topic: Time picker setting value via query or JS

belu pro asked 7 years ago

Hi, have severeal timepicker - fields in a form and I want to make a copy from above -  button next to the time picker field. I can get the value from the field above with var opening_time = $('#field_above').val(); but it is not possible to set the value of the target field via Jquery  - I tried $('#target_field').val(opening_time); How can I solve this? thanks Bernhard

belu pro commented 7 years ago

another question for time picker: is it possible to limit the minutes that can be chosen to 15,30,45,00 ? - so that it is not possible to choose e.g. 12:16

Mikołaj Smoleński staff answered 7 years ago

Hi, Here is the working code for changing time picker value:
 <div class="md-form">
  <input placeholder="Selected time" type="text" id="input_starttime" class="form-control timepicker">
  <label for="input_starttime">Light version, 12hours</label>
 </div>
 <button class="btn btn-primary" id="change-time">Change time</button>

 <script>
  $(document).ready(function() {
    $('#input_starttime').pickatime({});
    $('#change-time').on('click', function() {
      $('#input_starttime').val('5:39');
    })
  });
 </script>
For this moment, You can't limit the minutes as You wrote in the comment.
Regards

belu pro commented 7 years ago

hi, thx so far. Copying works, but the placeholder - label of the input field does not move up - so the copied value is printed above the label. This happens in chrome, safari and bravo. How can this be solved? The same problem occurs when you have e.g. at a login page the logindata saved in the browser for autofill... thx

Mikołaj Smoleński staff commented 7 years ago

Please share the code here. It should work similiar to the above example. Regards

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No