This is the html part
<html>
<head>
<script src="./js/ajax.js" type="text/javascript"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="./css/jquery-ui-timepicker-addon.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js">
</script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js">
</script>
<script type="text/javascript" src="jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="jquery-ui-sliderAccess.js"></script>
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
<script>
$('#datepicker').datetimepicker({
addSliderAccess: true,
sliderAccessArgs: { touchonly: false },
timeFormat: "hh:mm tt"
});
</script>
</head>
<div id="content">
</div>
</html>
the javascript ajax file is like this
function get_content(n)
{
//Create XMLHttpRequest Object
var hr=new XMLHttpRequest();
var url="./request_forward.php";
var vars="id="+n;
hr.open("POST",url,true);
//Set content type header information for sending url encoded variables in the request
hr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
//Access the onreadystatechange event for the XMLHttpRequest Object
hr.onreadystatechange=function()
{
if(hr.readyState==4 && hr.status==200)
{
var return_data=hr.responseText;
document.getElementById("content").innerHTML=return_data;
CKEDITOR.replace( 'txt1' );
}
}
hr.send(vars);
document.getElementById("content").innerHTML='<div style="width:300px;height:100px; margin:0 auto;margin-top:10%"><img style="width:300px;height:100px;" src="./img/loading.gif"></div>';
}
this is the dynamically loaded content into the div #content
<form id="add_program" method="post" name="add_program" enctype="multipart/form-data">
<label for="program_name">Program Name: </label>
<textarea id="program_name" name="program_name" rows="3" cols="100" required> </textarea>
<label for="from">From Date & Time: </label>
<input type="text" id="datepicker" name="from">
<label for="description">Description: </label>
<textarea class="ckeditor" id="txt1" name="description"></textarea>
<br/>
<label for="image">Upload Image: </label>
<input name="image" id="image" type="file"/><span class="notes">(allowed image types: gif, jpeg, jpg, png)</span>
<div style="width:10%; margin:0 auto; margin-top:10px"><input type="submit" name="add_program" value="Add Program" class="button"></div>
</form>
the date picker is not coming for the input text box "datepicker". i dont know jquery yet. how can i initialize the datepicker after loading the input box dynamically??