Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7713145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:47:56+00:00 2026-06-01T01:47:56+00:00

I am in a little bit of a bind. Another dept. at work asked

  • 0

I am in a little bit of a bind.

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’.

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.

Here are the js/jquery snippets:

$(document).ready(function() {
    $('#searchform').submit(function() {
        var valid = $('#searchbox').val();
        if(valid != '' && 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 && $(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');
                }
            });               
        });
    });
});

}

function buildFilter(){

var url = window.location.protocol + "//" + window.location.hostname + ":8080";
$.getJSON(url + "/alfresco/s/slingshot/category/assetCategories?callback=?&format=json", function(data){
    var filterHtml = "";
    $.each(data.categories, function(i, category){
        filterHtml += '<div id="div-check-' + category.title + '">';
        filterHtml += '<li class="group">';
        filterHtml += '<input id="' + category.title + '" name="' + category.title + '" type="checkbox" value="' + category.title + '" onclick="jqCheckAll(this.id, ' + "'all-"  + category.title + "'" + '); refineSearch();"/>';
        filterHtml += '<label id="' + category.title + '-label" for="' + category.title + '" class="filter-label">';
        filterHtml += '<span id="selectall-all-' + category.title + '">(select all)</span>';
        filterHtml += '<span id="clearall-all-' + category.title + '">(clear all)</span>';
        filterHtml += '</label>';
        filterHtml += '<h3 class="expand">' + category.label + '</h3>';
        filterHtml += '<div class="collapse">';
        filterHtml += '<ul id="all-' + category.title + '">';

        $.each(category.subcategory, function(j, sbcat){
            filterHtml += '<li>';
            filterHtml += '<input id="'  + sbcat.title + '" name="' + sbcat.title + '" type="checkbox" value="' + sbcat.title + '" onclick="jqCheckCheck(this.id, ' + "'" + category.title + "'" + ', ' + "'" + 'all-' + category.title + "'" + '); refineSearch();"/>';
            filterHtml += '<label for="' + sbcat.title + '">' + sbcat.label + '</label>';
            filterHtml += '</li>';
        });
        filterHtml += '</ul>';
        filterHtml += '</li></div>';
    });
    $("#refine-types > ul").append(filterHtml);
    $("h3.expand").toggler({speed: "fast"});
    checkFilterBoxes();
});

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:47:58+00:00Added an answer on June 1, 2026 at 1:47 am

    use e.preventDefault; so:

     $('#searchform').submit(function(**e**) {
            **e.preventDefault;**
            var valid = $('#searchbox').val();
            if(valid != '' && valid != 'Enter your keywords here'){
                $(':input[value=""]').attr('disabled', true);
            }else{
                alert('You must enter at least one keyword.');
                return false;
            }
    

    also, if you are going to use return false, place it outside the else block.. e.g.:

    $('#searchform').submit(function(**e**) {
            **e.preventDefault;**
            var valid = $('#searchbox').val();
            if(valid != '' && valid != 'Enter your keywords here'){
                $(':input[value=""]').attr('disabled', true);
            }else{
                alert('You must enter at least one keyword.');
                 **// instead of here**
            }
                **return false;**
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I do a little bit of third party javascript work for a company where
I'm a little bit new with knockout and I can't get the if data-bind
This little bit of code will help me describe my problem: public class Car
I'm in a little bit of a bind. I'm working with a legacy system
Say I have this little bit of code: public static void LoadSomething(Type t) {
This little bit of syntax has been a bit of a confusion for me
I'm a little bit lost here. In my nginx conf file I want a
I am little bit confuse that I am showing images through css it's working
I tweaked little bit how datetime picker works. It is triggered on change of
I am a little bit stuck up. First, I'll post the screenshot and then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.