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

The Archive Base Latest Questions

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

I have several select tags on a page and I am grouping them using

  • 0

I have several select tags on a page and I am grouping them using the data attribute to make sure those with the same data key can be compared. On submit, I want to check that the groups don’t have the same option value selected. So imagine it was a depth chart and you had football quarterbacks and running backs listed and you want to modify their position on the depth chart. I can’t have the two quarterbacks as #1 on the depth chart. All I need to do is alert the user….”Hey you can’t have the same value for this position” but I’m not sure how to do the comparison to get to that point using jQuery.

Quarterback A
<select data-position="qb">
  <option>1</option>
  <option>2</option>
</select>

Quarterback B
<select data-position="qb">
  <option>1</option>
  <option>2</option>
</select>

Runningback A
<select data-position="rb">
  <option>1</option>
  <option>2</option>
</select>

Runningback B
<select data-position="rb">
  <option>1</option>
  <option>2</option>
</select>
  • 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-01T09:35:49+00:00Added an answer on June 1, 2026 at 9:35 am

    I have just used classes to identify your groups, instead of the jQuery data attribute.

    Quarterback A
    <select class="qb">
      <option>1</option>
      <option>2</option>
    </select>
    
    Quarterback B
    <select class="qb">
      <option>1</option>
      <option>2</option>
    </select>
    
    Runningback A
    <select class="rb">
      <option>1</option>
      <option>2</option>
    </select>
    
    Runningback B
    <select class="rb">
      <option>1</option>
      <option>2</option>
    </select>
    
    <button id="eval">evaluate</button>
    

    ​

    Check this JS fiddle, i think it does what you want. If you need help explaining the code let me know,

    http://jsfiddle.net/SnJP4/5/

    I have set up a routine to bind to the click event of the “evaluate” button. If you were to add more positions, like wide reciever, etc. then just add the name of the class the the classes array. Here:

    $('#eval').click(function() {
        var classes = ['qb','rb'];
        $(classes).each(function(index, el){
            var list = [];
            $('.'+classes[index]).each(function() {
                //alert($(this).val());
                list.push($(this).val());
            });
            list = list.sort();
            for (var i = 0; i < list.length - 1; i++) {
                if (list[i + 1] == list[i]) {
                    alert('duplicate ' + classes[index]);
                    break;
                }
            }
        });
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using MySQL. I have several lookups like this: SELECT * from users
I have a DataTable which I select from database (Well, these data cross several
I have several 'select' elements on the page. When I choose some of options,
I have several select boxes and textboxes with the same class and I have
I have several select lists on a page. They are all named in array-fashion
I have several nodes with some particular attribute and I need to select one
I have several div s, and I want to select them if they contain
I have a form which has several tags. is this possible: <select name=select1 id=select1>
I have several SELECT statements on a PHP page, and I used Dreamweaver to
Say I have a stored procedure consisting of several separate SELECT, INSERT, UPDATE and

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.