I am using this code
window.onload = function(){
new JsDatePick({
useMode:2,
target:"report_date_start",
dateFormat:"%d-%M-%Y"
});
new JsDatePick({
useMode:2,
target:"report_date_end",
dateFormat:"%Y-%m-%d"
});
};
function dwnyear_click(id)
{
var urls=siteurl+"?action=Date_range&id="+id;
$.ajax({
type: "POST",
url: urls,
success: function(msg)
{
$("#dwn_year").html(msg);
$("#dwnyear_dropdown").css("display","none");}
});
}
<input name="report_date_start" type="text" id="report_date_start" />
<input name="report_date_end" type="text" id="report_date_end" />
I need to load the textboxes to form via ajax, the datepicker is not working. I have used the same datepicker in my site without any problems. How to tackle this problem? I have added ajax code. Onsuccess returns the textfields
I don’t think the window.onload event will trigger when you are loading that code in via an AJAX request as the page has already loaded.
You should try having your Javascript on the original page, or maybe rather than using that event put the code into an AJAX success event instead which will trigger when the AJAX request has completed successfully.