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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:50:56+00:00 2026-06-05T14:50:56+00:00

I have a <SELECT multiple=multiple> box with options. I store the selected options in

  • 0

I have a <SELECT multiple="multiple"> box with options.

I store the selected options in a JS variable – selectedFeatures.

I want to pass selectedFeatures array variable of options to jQuery.inArray() – but the function is designed to take and check for one value only.

I can show/hide( or filter ) the markers on my map if I actually specify an index of an element like so: selectedFeatures[0] inside inArray()

..but since I may select multiple options from a select box this method of filtering doesn’t work.

How can I check if an array of items in found inside another array with JS/jQuery?

// store selected options as an array of string elements inside the variable
var selectedFeatures = $("#features").val();
// for every element inside 'markers.houses' array...                   
$(markers.houses).each(function(index, elem){
    // check if any of the values inside the 'selectedFeatures' array are found
    // also inside a sub-array 'features' inside every element of 'markers.houses'
    // array. if 'true' show that particular marker, otherwise hide the marker
    if(jQuery.inArray(selectedFeatures, elem.features) !== -1 || jQuery.inArray(selectedFeatures, elem.features) > -1){
        markers.houseMarkers[index].setVisible(true);
    }else{
        markers.houseMarkers[index].setVisible(false);
    }
});

Fig 1.1 – store selected options in an array variable and use it with jQuery.inArray()

  • 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-05T14:50:57+00:00Added an answer on June 5, 2026 at 2:50 pm

    What you are asking for can be solved with PHP’s array_diff function. I know you’re not using PHP, but that’s why there is array_diff on PHPJS, a project dedicated to porting PHP functions into JavaScript.

    Anyway, to solve this you basically want to call array_diff(selectedFeatures,elem.features).length == 0. (You may need to swap the arguments around, I’m not sure which array is which in your question)

    array_diff returns the elements of the first array that are not present in the others. If all of the elements in the first array are also in the second array (ie. array1 is a subset of array2), then the returned array will be empty, hence its length is zero.

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

Sidebar

Related Questions

I have used Multiple select Box in edit form, displaying previously selected items in
I have a selection box that allows you to select multiple options. I need
I have a form with a select box that allows multiple options. After a
I have two multiple select boxes. I need to use JQuery to drag selected
I have a select box in which i can select multiple options. In the
I have an edit form that contains multiple select fields with selected options. Is
I have I datagrid, on which I want to select multiple rows on a
I have multiple multi-select boxes with the same class and i want to unselect
i have two select box, now what i want is i want to move
I have a javascript function below to move from select multiple box A which

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.