Hi there,
I am very new to JQuery and found a great function that adds days to a date. Here is the link to the working Jfiddle example
I took this code so that I could test it locally but it will not function. The error I am getting is
SCRIPT5009: '$' is undefined test.html (19,1)
SCRIPT7002: XMLHttpRequest: Network Error 0x3, The system cannot find the path specified.
Here is the source that I took from the Jfiddle example
Any advice on this would be really helpful as I have been chasing my tail for a while now.
Thanks for looking.
I am very new to JQuery and found a great function that adds days to a date. Here is the link to the working Jfiddle example
I took this code so that I could test it locally but it will not function. The error I am getting is
SCRIPT5009: '$' is undefined test.html (19,1)
SCRIPT7002: XMLHttpRequest: Network Error 0x3, The system cannot find the path specified.
Here is the source that I took from the Jfiddle example
Any advice on this would be really helpful as I have been chasing my tail for a while now.
Thanks for looking.
Code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.0.js"></script>
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<title></title><script type='text/javascript'>//<![CDATA[
$(window).load(function(){
;(function($, window, document, undefined){
$("#days").on("change", function(){
var date = new Date($("#start_date").val()),
days = parseInt($("#days").val(), 10);
if(!isNaN(date.getTime())){
date.setDate(date.getDate() + days);
$("#end_date").val(date.toInputFormat());
} else {
alert("Invalid Date");
}
});
//From: [URL unfurl="true"]http://stackoverflow.com/questions/3066586/get-string-in-yyyymmdd-format-from-js-date-object[/URL]
Date.prototype.toInputFormat = function() {
var yyyy = this.getFullYear().toString();
var mm = (this.getMonth()+1).toString(); // getMonth() is zero-based
var dd = this.getDate().toString();
return yyyy + "-" + (mm[1]?mm:"0"+mm[0]) + "-" + (dd[1]?dd:"0"+dd[0]); // padding
};
})(jQuery, this, document);
});//]]>
</script>
</head>
<body>
<input type="date" id="start_date" placeholder="Start Date"/>
<input type="number" id="days" placeholder="Days"/>
<input type="date" id="end_date" placeholder="End Date" readonly/>
<script>
// tell the embed parent frame the height of the content
if (window.parent && window.parent.parent){
window.parent.parent.postMessage(["resultsFrame", {
height: document.body.getBoundingClientRect().height,
slug: "MCzJ6"
}], "*")
}
</script>
</body>
</html>