$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>javascript - select is not defined, jQuery UI - Stack Overflow|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - select is not defined, jQuery UI - Stack Overflow

matteradmin10PV0评论

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 plete source code

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 plete source code

Share Improve this question asked Jan 13, 2015 at 18:46 Node.JSNode.JS 1,6347 gold badges55 silver badges131 bronze badges 1
  • 5 It's not defined because you didn't define it anywhere, you just randomly typed select as a value in an object, and there's no variable named select in your code. – adeneo Commented Jan 13, 2015 at 18:47
Add a ment  | 

1 Answer 1

Reset to default 4

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.

Post a comment

comment list (0)

  1. No comments so far