javascript - how to make onclick event when clicking the date from datepicker UI -
hi guys have try make select data function jquery onclick event have triggering date datepicker. have try make code seems not work @ all.
this textboxt id's contain datepicker call function. $(#date)
have try make code selecting data. code.
$(document).on('click','#date',function(e) { var data = $("#form_input10").serialize(); $('#table_s tbody').empty(); $.ajax({ data: data, type: "post", url: "../php/termocouple/get_date.php", success: function(data){ var list = json.parse(data); for(var = 0; < list.length; i++){ $('#date1').val((list[i]['tanggal2'])); } } }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
the condition when datepicker running this. when textbox clicked datepicker showing. nah when use code, condition 1st click show datepicker ( condition textbox doesn't have value of date) the datepicker showing , select date. need 1 click again on textbox showing data.
please me solve please
instead of trying use click event on datepicker, you'd want use 1 of datepicker's available options. 1 beforeshow, , allows have function run before datepicker opens up:
$( "#date" ).datepicker({ beforeshow: dothatthing }); function dothatthing(){ var data = $("#form_input10").serialize(); $('#table_s tbody').empty(); $.ajax({ data: data, type: "post", url: "../php/termocouple/get_date.php", success: function(data){ var list = json.parse(data); for(var = 0; < list.length; i++){ $('#date1').val((list[i]['tanggal2'])); } } }); }
Comments
Post a Comment