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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:54:59+00:00 2026-06-11T05:54:59+00:00

I have a form and use Jquery to create an array called fields when

  • 0

I have a form and use Jquery to create an array called “fields” when an input is changed:

var fields = $(":input").serializeArray();

I then use this array in an .each function to display a list of items:

jQuery.each(fields, function(i, field){

//get multiple values into array and perform action for each
val = field.value;
name = field.name;
var valarray = val.split(',');
for (var i in valarray) {
    //get each answer
    val = $.trim(valarray[i]);

    $("#pid"+val).show();
}//end for
});//end each

At the moment the console.log shows this if 3 radio buttons are selected:

[Object { name= "question1" ,  value= "aa,bb,cc,dd" }, Object { name= "question2" ,  value= "bb,cc" }, Object { name= "question3" ,  value= "cc,ee" }]

And all values aa, bb, cc, dd and ee are shown.

What I would like to do, rather than showing all values, is compare the values of each question and only show the ones that appear in ALL questions (cc in this example). The idea is to filter the list so if only question1 and question2 have been selected, “bb” and “cc” would be shown. Further to that, if a 4th question is selected with the value “dd” and there isn’t therefore a value that matches all the questions, I’d like to return an alert and remove/deselect the last value, therefore reverting back to just “cc”.

I can’t work out how to compare the values to show only matching ones. I’ve used code from a few answers on stackoverflow and I’ve tried counting instances but seem to be going round in circles so any help would be greatly appreciated.

I hope I’ve given you enough info. Thanks.

  • 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-11T05:55:01+00:00Added an answer on June 11, 2026 at 5:55 am

    I don’t know whether I managed to catch everyone out or if this was just missed but I worked out a solution by counting the occurences of each answer and where this equals the amount of questions asked (ie, the answer appears for all questions), adding it to another array. Thanks anyway!

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

Sidebar

Related Questions

I have a form with multiple input fields that use datepicker. I have just
I have a standard form in mvc4 operation. I use jQuery.post to perform postback
I have a small jQuery plugin that I use for form AJAX validation. There
Quick question, is it possible to have an input field in a form use
I have my form in a table and I use this code to add
I have an C# form application that use an access database. This application works
I have a form on a page that a user can use to create
I have a view called volunteer_edit. Within volunteer_edit, I use jQuery to loop through
I have a dynamically generated form with input fields with the same name (for
I have a few areas in a form I'm producing where I use jquery

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.