javascript - Find duplicate values in pairs - select dropdown -


i have pair of text boxes. need find duplicate pair values in select dropdown.

jsfiddle example

txt12    txt12 txt2     txt1 txt3     txt3 txt4     txt5 txt12    txt12 

in example, txt12 select pair duplicated. possibly find each duplicate values considering each select dropdowns.

 var selects = document.getelementsbytagname('select');  var values = [];  for(i=0;i<selects.length;i++) {     var select = selects[i];     if(values.indexof(select.value)>-1) {         alert('duplicate - '+select.value); break;     }     else          values.push(select.value);  } 

how possible find duplicate pair of select dropdown values

you can use

function chkval() {     var selects = document.getelementsbytagname('select');     var values = [];     for(i=0;i<selects.length;i++) {         var select = selects[i];         if(values.indexof(select.value)>-1) {             alert('duplicate - '+select.value);         }         else              values.push(select.value);     } } 

you have remove break in if block moving out of for loop in first loop when find text12.

refer fiddle : "http://jsfiddle.net/sl6ofchd/9/"


Comments