title: Variable is not defined
body: <p>I'm working on a jquery where user selects a category and then a range of years.
  my problem is I'm getting <code>cats is not defined</code> although it is, and I can see it using <code>alert(cats);</code> from <code>$('[id^="multi-"]').click(function () {</code></p>
  
  <p>but when i'm choosing the range of years, from <code>$("#multi_select_wrapper").keyup(function(){</code> "cats" variable is not defined</p>
  
  <pre><code>$('[id^="multi-"]').click(function () {
              $(this).toggleClass('selected');
              var cats = [];
              $(".selected").each(function(){
                  cats.push($(this).attr('data-id'));
              });
              var cats = cats.join(",");
              alert(cats);
      });
  
              $("#multi_select_wrapper").keyup(function(){
                      if(f_year!==null &amp;&amp; t_year!==null){
                              var years = [];
                              var counter = parseInt(t_year)+1;
  
                              for (var i = f_year; i &lt; counter; i++) {
                                      years.push(i);
                              }
                              alert(years);
                              alert(cats);
                      }
                      $("#multi_search").attr("href", "index.php?do=m&amp;msc=" + cats + "&amp;msy=" + years);
              });
  </code></pre>