JavaScript working on fiddle but not in site

Good day!

I have recently acquired a code and was passed on using fiddle. It works fine on the fiddle but when I am trying to implement it on my site.

Head tag contains:

<head>
<title>NQA Insert</title>
<script type="text/javascript" src="NQAa.js">
</script>
</head>

While NQA.js contains:

$('#bill50').on('change', function() {
var date30 = new Date($(this).val());
date30.setDate(date30.getDate()+30);
var date20 = new Date($(this).val());
date20.setDate(date20.getDate()+60);
$('#bill30').val(date30.toJSON().slice(0,10));
$('#bill20').val(date20.toJSON().slice(0,10));
});

Note 1: If you input a date on bill50, the value on bill30 and bill20 also changes. Note 2: I am implementing this on a php page. Maybe this helps...

Why is it that when implementing it on the site, it doesn't work at all? Is there anything wrong in my calling of the jscript..?

Upvotes: 0

Views: 138

Answers (1)

Anas Bouhtouch
Anas Bouhtouch

Reputation: 546

you need to include the jQuery library, as you can see in your jsFiddle he's including jQuery 1.8.3, you should add it in your "head" tag just before the js script you bought.

You'll get something like this:

<head>
<title>NQA Insert</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js">
<script type="text/javascript" src="NQAa.js">
</script>
</head>

Upvotes: 2

Related Questions