Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Datetimepicker XDsoft: How do I get value from inline calendar?

I use the jQuery Datetimepicker plugin from XDSoft: http://xdsoft.net/jqplugins/datetimepicker/

I have the calender displayed inline. Here comes my code:

HTML:

<input type="text" id="start_date">

JS:

jQuery('#start_date').datetimepicker({
  format:'d.m.Y H:i',
  inline:true
});

My problem: When I pick a date in the frontend, the input field does not get the selected date as a value. What changes do I need to make or what do I need to add?

like image 920
Kent Miller Avatar asked Jun 08 '14 12:06

Kent Miller


2 Answers

Get value from Onchange Event

Try this

onChangeDateTime:function(dp,$input){
            $('#datePickValue').text($input.val());
        }

Full Code look like this

jQuery('#start_date').datetimepicker({
  format:'d.m.Y H:i',
  inline:true,
  onChangeDateTime:function(dp,$input){
    $('#start_date').text($input.val()); // change the div as per your need - change the text as val ( it depends on the field)
  });
like image 153
Madhavan Avatar answered Nov 18 '22 02:11

Madhavan


Use the date time picker event.

HTML

<input type="hidden" id="start_date">

JS

var $startDate = $('#start_date');

$startDate.datetimepicker({
  inline:true,
  sideBySide: true
});

$startDate.on('dp.change', function() {
  var selectedDate = $(this).val();
  alert(selectedDate);
});

JS Fiddle Demo

like image 28
Adrian Enriquez Avatar answered Nov 18 '22 01:11

Adrian Enriquez