Node.JS
Node.JS

Reputation: 1582

select is not defined, jQuery UI

I was practicing with data picker in jQuery UI and I got into problem that I could't solve.

I wanted to calculate the difference of given date (from date picker) and today's date in days, after user clicked calculate button.

I get this error:

Uncaught ReferenceError: select is not defined(anonymous
    function)
j
k.fireWithjQuery.js: 2
m.extend.readyjQuery.js: 2
J

Here is my code:

    $(document).ready(function() {
        $("#calculate").click(function() {
            var d1 = $(".date-pick").datepicker("setDate", new Date());
            var d2 = $("#startDate").datepicker('getDate');
            var diff = 0;
            if (d1 && d2) {
                diff = Math.floor((d2.getTime() - d1.getTime()) / 86400000);
            }
            $('#calculated').val(diff);
        });
        $("#startDate").datepicker({
            onSelect: select
        });
    });

Here is my complete source code

Upvotes: 2

Views: 11363

Answers (1)

zavg
zavg

Reputation: 11071

You simply have not defined select function anywhere in your source code (all your custom js-code is currently in your index.html, so it is easy to figure it out), but you are trying to use it as onSelect event handler.

Upvotes: 4

Related Questions