Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call a js function onSelect event of datepicker jquery?

Please anyone help me.. I have a js function

function updateAb(param){ some manipulation }

And i am calling a datepicker jquery onselect event like..

$( ".datepicker").datepicker({onSelect: function(dateText, inst) { ... }});

I want to call the js function in select, how to do that? My objective is to get the value onselect of date from the datepicker and setting the attribute value in input field. Can anyone help me???

like image 992
Rahul Avatar asked Jun 01 '12 06:06

Rahul


3 Answers

Here goes ur code

$('.datepicker').datepicker({
    dateFormat: 'dd-mm-yy',
    numberOfMonths: 1,
    onSelect: function(selected,evnt) {
         updateAb(selected);
    }
});

function updateAb(value){     
    $('#yourInputID').val(value);    
}
like image 168
Kabilan S Avatar answered Nov 15 '22 16:11

Kabilan S


$( ".datepicker").datepicker({
    onSelect: function(dateText, inst) { 
        updateAb(dateText);
    }
});

Even more simply, if you do want the dateText and inst parameters to be passed to updateAb

$( ".datepicker").datepicker({onSelect: updateAb});
like image 35
Juan Mendes Avatar answered Nov 15 '22 15:11

Juan Mendes


$( ".datepicker").datepicker({
       onSelect: function(dateText, inst) {
          updateAb(dateText, inst);
       }
});

In short

$( ".datepicker").datepicker({
    onSelect: updateAb
});
like image 30
thecodeparadox Avatar answered Nov 15 '22 16:11

thecodeparadox