dev1234
dev1234

Reputation: 5716

Jquery UI Multi datepicker issue on retrieving dates

i am using this http://multidatespickr.sourceforge.net/#method-addDates to enable multiple date select. everything works fine but i am wondering how to get the selected dates to PHP.

below is the html code.

<input type="text" name="outgoing_call_dates" value="" id="outgoing_call_dates_id" class="hasDatepicker">

as you can see value tag is empty always when i add, its normally appending to the end but not value tag is doing the same. please check this image.

Original source : http://multidatespickr.sourceforge.net/#method-addDates (example : From input)

Please help me find a wayenter image description here

Upvotes: 1

Views: 1041

Answers (3)

Shareek Ahamed
Shareek Ahamed

Reputation: 378

Please have a look @ this....! Hope this will fix your issue :)

<no codes :|>

http://jsfiddle.net/3t4j9/23/

Upvotes: 1

SergkeiM
SergkeiM

Reputation: 4168

HTML

<input id="datePick" type="text"/>

<input id="get" type="button" value="Get" />

JS

$('#datePick').multiDatesPicker();

$('#get').on("click",function(){
    var dates = $('#datePick').val();
        if(dates !=''){
        dataString = 'dates='+dates;
        $.ajax({
                 type:"POST",
                 url : "URL_TO_PHP_FILE",
                 data : dataString,
                 dataType : 'json',
                 success : function(data) {
                    alert(data);
               }
        )};
      }
});

PHP

$dates = ($_POST['dates']);
 echo json_encode($dates);

Upvotes: 2

ksg91
ksg91

Reputation: 1299

value attribute defines default value. If you change the value of input element, it won't be inside source with value="YOUR_ENTERED_VALUE" .

To access value in client side, you can use JS or jQuery.

For example using jQuery:

var dates = $('#outgoing_call_dates_id').val();

In pure JS:

var dates = document.getElementById('outgoing_call_dates_id').value;

For PHP, when you'll receive it on your action page. On that page,

use this:

$dates = $_POST['outgoing_call_dates'];

or

$dates = $_GET['outgoing_call_dates'];

depending on the method you use.

Upvotes: 1

Related Questions