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 8380081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:21:55+00:00 2026-06-09T16:21:55+00:00

I am using the following jQuery multiselect script on the select boxes on my

  • 0

I am using the following jQuery multiselect script on the select boxes on my website, the problem is when I click the select boxes it is reloading the page each time, the way I want it to function is just to select the different options from the select box and then click the submit button, as present as soon as I click any of the select boxes the page gets reloaded.

/* jquery.ui.muliselect.js
 *
 * URL: http://corydorning.com/projects/multiselect
 *
 * @author: Cory Dorning
 * @modified: 08/25/2011
 *
 * Multiselect is a jQuery UI widget that transforms a <select>
 * box to provide a better User Experience when you need to select
 * multiple items, without the need to use the CTRL key.
 *
 * 
 * @TODO
 * 
 *
 */

(function($) {
  $.widget('ui.multiselect', {
    _version: 0.1,

    version: function() { return this._version },

    // default options
    options: {
      label: '-- Select --',
      minWidth: 200,
      maxWidth: null,
      scroll: 0
    },

    items: [],

    _create: function() {
      var self = this,
          $select = self.element.hide(),
          items = self.items = $select.children('option').map(function(){
            return {
              label: $(this).text(),
              value: $(this).text(),
              option: this // this stores a reference of the option element it belongs to
            };
          }).get();

      var $input = self.input = $('<div class="ui-multiselect-input" />')
            .attr({
              // workaround to close menu on blur
              tabIndex: -1
            })
            .html('<span class="ui-multiselect-label" style="display: inline-block; margin: 2px; padding: 1px;">' + self.options.label + '</span>')
            .insertAfter($select)
            .autocomplete({
              delay: 0,
              minLength: 0,
              source: function(req, resp) {
                var srcItems = [];

                $.each(items, function(i, o) {
                  if (!o.option.selected) {
                    srcItems.push(o);
                  }
                });
                resp(srcItems);
              },
              select: function(ev, ui) {
                $.each(items, function(i, o) {
                  if (ui.item.option === o.option) {
                    self.select(i);
                  }
                });
              }
            })
            .addClass('ui-widget ui-widget-content ui-corner-left')
            .css({
              display: 'inline-block',
              minWidth: self.options.minWidth,
              maxWidth: self.options.maxWidth || 'auto',
              padding: 1,
              verticalAlign: 'middle'
            })
            .click(function() {
              self.button.trigger('click');
            });

      self.button = $('<button>')
        .insertAfter($input)
        .button({
          icons: {
            primary: 'ui-icon-triangle-1-s'
          },
          text: false
        })
        .removeClass('ui-corner-all')
        .addClass('ui-corner-right')
        .css({
          height: $input.outerHeight(),
          verticalAlign: 'middle'
        })
        .click(function() {
          // close if already visible
          if ( $input.autocomplete('widget').is(':visible') ) {
            $input.autocomplete('close');
            return;
          }

          // work around a bug (likely same cause as #5265)
          $(this).blur();

          // pass empty string as value to search for, displaying all results
          $input.autocomplete('search', '');
          $input.focus();
        });

      if (self.options.scroll) {
        $('.ui-autocomplete').css({
          maxHeight: self.options.scroll,
          overflowY: 'auto',
          overflowX: 'hidden',
          paddingRight: '20px'
        });
      }

    }, // _create

    destroy: function() {
      this.input.remove();
      this.button.remove();
      this.element.show();
      $.Widget.prototype.destroy.call( this );
    }, // destroy

    select: function(index) {
      var self = this,
          item = self.items[index];

      item.option.selected = true;

      $('<span class="ui-multiselect-item">' + item.label + '</span>')
        .button({
          icons: { secondary: 'ui-icon-close' }
        })
        .css({
          cursor: 'default',
          margin: 2
        })
        .children('.ui-button-text')
          .css({
            lineHeight: 'normal',
            paddingTop: 0,
            paddingBottom: 0,
            paddingLeft: '.5em'
          })
          .end()
        .children('.ui-icon-close')
          .css({
            cursor: 'pointer'
          })
          .click(function() {
            $(this).parent().remove();
            self.deselect(item);
            return false;
          })
          .end()
        .appendTo(self.input);

        self.element.trigger('change');

        self.input.children('.ui-multiselect-label').hide();
    }, // select

    deselect: function(item) {
      var self = this;

      item.option.selected = false;

      self.element.trigger('change');

      if (!self.input.children('.ui-multiselect-item').length) {
        self.input.children('.ui-multiselect-label').show();
      }
    } // deselect

  }); // $.widget('multiselect')
})(jQuery);

This is the code I am using in my template index.php file >>

      <!-- Multiselect Library-->
                        <script type="text/javascript" src="./multiselect/jquery.ui.multiselect.js"></script>

    <script>
    $(function() {
      // initialize the plugin
      $('select').multiselect();

      $('.w-options').multiselect({
        label: '-- Select Your Options --',
        minWidth: 300,
        maxWidth: 400,
        scroll: 80
      });
    })
    </script>
  • 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-09T16:21:56+00:00Added an answer on June 9, 2026 at 4:21 pm

    You need to update this method in plugin file…

    .click(function() {
      // close if already visible
      if ( $input.autocomplete('widget').is(':visible') ) {
        $input.autocomplete('close');
        return;
      }
    
      // work around a bug (likely same cause as #5265)
      $(this).blur();
    
      // pass empty string as value to search for, displaying all results
      $input.autocomplete('search', '');
      $input.focus();
    });
    

    to instead be

    .click(function(e) {
      e.preventDefault();
      // close if already visible
      if ( $input.autocomplete('widget').is(':visible') ) {
        $input.autocomplete('close');
        return;
      }
    
      // work around a bug (likely same cause as #5265)
      $(this).blur();
    
      // pass empty string as value to search for, displaying all results
      $input.autocomplete('search', '');
      $input.focus();
    });
    

    This should prevent browser from doing anything on click

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following jQuery plugins (along with the jQuery plugin): <script type=text/javascript src=scripts/jquery.scrollTo-min.js></script>
I'm using the following jQuery code to remove options from a select and it
I'm using the following jquery multiselect plugin ... How can I grab the selected
I'm using the following jquery multiselect plugin ... How can set the selectedText as
I'm using the following jQuery script to calculate the total width of ul based
I am using following jQuery code to toggle between the tabs on a page:
I'm fetching JSON from my ASP .NET website using the following jQuery: $.ajax({ type:
I am using the following jquery code to open a modal popup on click
Hi I am using the following jquery to make a div cliackable (for page
I'm using the following jQuery script to highlight a table row on mouseover. input.find(tr).live('mouseover

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.