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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:57:57+00:00 2026-06-08T04:57:57+00:00

I am trying to compare the value of many select values and interchange them

  • 0

I am trying to compare the value of many select values and interchange them when they are same as I have tried in my code,

function OnChangeSelection(selection,selectid)
{
    var count=1;
    for(var j=5;j<=14;j++)
    {
        var c_id= "Numbering"+count;
        if (document.getElementById(selectid).value == document.getElementById(c_id).value) 
        {
            alert(c_id);
        }
        count++
    }
} 

in this code I am getting perametera “selection is the value changed on selection ” and “selectid” is the id of the select tag” so I wanna compare it in loop because I have 10 select and matching it via its id that would I generate by conacating Numbering+count and when it match it with another select value it prints that select id but issue is that it is printing the id of the another select and also the id of the select from which I am comparing it.

  • 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-08T04:57:59+00:00Added an answer on June 8, 2026 at 4:57 am

    I think you’re comparing your element with itself at some point. Put some condition to skip self comparing:

    function OnChangeSelection(selection,selectid)
    {
        var count=1;
        for(var j=5;j<=14;j++)
        {
            var c_id= "Numbering"+count;
            if (c_id == selectid) {count++;continue;}
            if (document.getElementById(selectid).value == document.getElementById(c_id).value) 
            {
                alert(c_id);
            }
            count++
        }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to compare two decimal values in Java script. I have two
I am trying to compare the value of 2 instances of x inside an
I am trying to compare a value which was grabbed using the get method
I am trying to compare values on data frame rows, and removing all the
I'm trying to compare two arrays and get only the values that exist on
I am trying to compare two tools execution time, which I have installed in
i'm trying to compare a value to an Enum in Struts: <s:if test=%{myValue ==
I'm trying to find out if two strings I have are the same, for
I'm trying to compare the value of the password stored in the database (which
I'm trying to compare one attribute value to another, if it returns true i

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.