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.
I think you’re comparing your element with itself at some point. Put some condition to skip self comparing: