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

  • Home
  • SEARCH
  • 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 8454513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:02:58+00:00 2026-06-10T12:02:58+00:00

Using jQuery Multiselect plugin and need to check if any selections have been made

  • 0

Using jQuery Multiselect plugin and need to check if any selections have been made (user may open and close select box without choosing anything). This plugin has a “close” method which I use to get the array of selected/checked options:

var checkedVals = [];
checkedVals = $('#'+which).val();   // Get Array of checked options
alert(checkedVals.length);      // See if it's empty

When an option is selected/checked, it works fine (so I know I’m returning values) but when nothing is selected, Firebug throws an error stating that checkedVals is null. An empty array should be 0… not null. And pls… let’s not get into the discussion of trying to trap “null”.

Thanks for any help

  • 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-10T12:02:59+00:00Added an answer on June 10, 2026 at 12:02 pm

    Write it like this and you will always have an array

    var checkedVals = $('#'+which).val() || [];
    alert(checkedVals.length);      
    

    It will set checkedVals to the .val() value or to an empty array if it’s null (falsey).

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

Sidebar

Related Questions

I am using jquery multiselect plugin, If an option has been selected i would
I'm using the jquery multiselect control from: http://abeautifulsite.net/notebook/62 I need to manually check one
I am using the excellent jQuery MultiSelect plugin. The problem I have is that
I'm using Datatables and have this jquery plugin showing in a few columns http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/
I am using jquery multiselect in my project,when user clicks on checkall then how
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 am using a jquery multiselect plugin http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/ with option. All works fine, however
I need to create a custom jquery form validation using Jquery Validation Plugin where
I'm using this plugin http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/ and it works awesome!! but I'd like to make

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.