onSelect
is an event callback, you are trying to return a value before it knows what to do. it's not going to be possible to have your test()
return the value, because it comes later.
you should do your alert or whatever logic from within the event callback:
$('#d1').datepicker({
onSelect: function() {
sdate = $(this).val();
$("#dd").dialog("close");
alert(sdate);
// or your own function
someOtherTest(sdate);
}
});
-
function someOtherTest(date) {
alert(date);
}