title: Using JQuery to prevent page refresh when user clicks submit on a search box inquiry or filter
body: <p>I am in a little bit of a bind.  </p>
  
  <p>Another dept. at work asked me to look over the following HTML code.  They are asking me to figure out why when someone enters data in the search box form and clicks submit the page refreshes.  They do NOT want the page to refresh when either clicking the submit button or when selecting any of the 'filters'.</p>
  
  <p>I have been looking over the code now for a few hours and I am not well versed enough with JQuery to know where to look for the 'Page Refresh' functionality.</p>
  
  <p>Here are the js/jquery snippets:</p>
  
  <pre><code>$(document).ready(function() {
      $('#searchform').submit(function() {
          var valid = $('#searchbox').val();
          if(valid != '' &amp;&amp; valid != 'Enter your keywords here'){
              $(':input[value=""]').attr('disabled', true);
          }else{
              alert('You must enter at least one keyword.');
              return false;
          }
  
      });   
  
  $( '#app-prefilter input[type=radio]').each(function() {   
       if ( $(this).val() == $("#prefilter" ).val() ) {
          $(this).attr("checked", true);
       }
  });               
  
  // If user clicks on an option, set prefilter field, and submit form
  $("#app-prefilter").click(function() {
      var allVals = [];
      $( '#app-prefilter :checked').each(function() {
         allVals.push($(this).val());
      });
      $( '#prefilter').val(allVals);   
      $( "#" + 'searchform').submit();        
  });     
  
  
  function checkFilterBoxes() {
  $("#searchform input").each(function() {    
      $(this).each( function() {
          filters = $(this).val().split(',');
          name = $(this).attr('name');
          $.each( filters, function(index, value) {
              $('#all-' + name  + ' ' + 'input[type=checkbox]').each(function(){  
                  //alert($(this).val() + ":" + value + ":" + $(this).attr('checked'));
                  if ( $(this).val() == value &amp;&amp; $(this).attr('checked') != 'checked') {
                      //alert("set " + $(this).val() + " to checked");
                      $(this).attr("checked", true);
                      $(this).parent().css('display', 'block');
                      $(this).closest("div").css('display', 'block');
                      $(this).parents(".group").find('a').removeClass("open");
                  }else if($(this).attr('checked') == 'checked'){
  
                  }else{
                      //alert("hide " + $(this).val());
                      $(this).parent().css('display', 'none');
                  }
              });               
          });
      });
  });
  </code></pre>
  
  <p>}</p>
  
  <pre><code>function buildFilter(){
  
  var url = window.location.protocol + "//" + window.location.hostname + ":8080";
  $.getJSON(url + "/alfresco/s/slingshot/category/assetCategories?callback=?&amp;format=json", function(data){
      var filterHtml = "";
      $.each(data.categories, function(i, category){
          filterHtml += '&lt;div id="div-check-' + category.title + '"&gt;';
          filterHtml += '&lt;li class="group"&gt;';
          filterHtml += '&lt;input id="' + category.title + '" name="' + category.title + '" type="checkbox" value="' + category.title + '" onclick="jqCheckAll(this.id, ' + "'all-"  + category.title + "'" + '); refineSearch();"/&gt;';
          filterHtml += '&lt;label id="' + category.title + '-label" for="' + category.title + '" class="filter-label"&gt;';
          filterHtml += '&lt;span id="selectall-all-' + category.title + '"&gt;(select all)&lt;/span&gt;';
          filterHtml += '&lt;span id="clearall-all-' + category.title + '"&gt;(clear all)&lt;/span&gt;';
          filterHtml += '&lt;/label&gt;';
          filterHtml += '&lt;h3 class="expand"&gt;' + category.label + '&lt;/h3&gt;';
          filterHtml += '&lt;div class="collapse"&gt;';
          filterHtml += '&lt;ul id="all-' + category.title + '"&gt;';
  
          $.each(category.subcategory, function(j, sbcat){
              filterHtml += '&lt;li&gt;';
              filterHtml += '&lt;input id="'  + sbcat.title + '" name="' + sbcat.title + '" type="checkbox" value="' + sbcat.title + '" onclick="jqCheckCheck(this.id, ' + "'" + category.title + "'" + ', ' + "'" + 'all-' + category.title + "'" + '); refineSearch();"/&gt;';
              filterHtml += '&lt;label for="' + sbcat.title + '"&gt;' + sbcat.label + '&lt;/label&gt;';
              filterHtml += '&lt;/li&gt;';
          });
          filterHtml += '&lt;/ul&gt;';
          filterHtml += '&lt;/li&gt;&lt;/div&gt;';
      });
      $("#refine-types &gt; ul").append(filterHtml);
      $("h3.expand").toggler({speed: "fast"});
      checkFilterBoxes();
  });
  </code></pre>
  
  <p>}</p>