I added this code in the head:
<script>
function cpf(pag) {
request = createRequest();
if(request == null) {
alert("Unable to Create Request");
return;
}
var nocache = new Date();
var url = "https://pathto.com/cp/gettime.php?t="+pag;
url = url + "&stopIEcache="+ nocache;
request.open("GET",url,true);
request.onreadystatechange = showtpage;
request.send(null);
}
function showtpage() {
if(request.readyState == 4) {
if(request.status == 200) {
detailDiv = document.getElementByName("newtdf")[0];
detailDiv.innerHTML = request.responseText;
}
}
}
function createRequest() {
try {
request = new XMLHttpRequest();
} catch (tryMS) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (otherMS) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = null;
}
}
}
return request;
}
</script>
Here is my HTML output by php:
<input type="text" value="2014/10/10 05:08" id="datetimepicker" name="newtd" onBlur="cpf(document.getElementByName('newtd')[0].value);" /><br />
Epoch Timestamp Built: <input type="text" name="newtdf" size="10" value="">
So I have the first field that is selectable by a datetimepicker, when they leave the field (onblur), it should run the cpf function I created on the script, and pass the value of the field to it.
But it is not working.
I ran it and with the debugger, it says this:
Uncaught TypeError: undefined is not a function
can you help me fix it please?