Verification of the same selected values in different selectors



  • This form interface is available: введите сюда описание изображения

    in this particular example, each selects different meanings.

    We've got to run the checks for the same selected values in different parts, like here:

    введите сюда описание изображения

    This is where the "Presidium" is chosen in Part One and Part Two, which is a mistake in the form logic.

    How is this verification on the same selected values in different select's forms to be applied to JavaScript?



  • Elementary - you get the selected elements from both selters and compare, for example, at the time of the element selection in any of the selters.

    var select1 = /* document.querySelector... */ ;
    var select2 = /* ... */ ;
    

    var selected1 = Array.from(select1).filter(e => e.selected);
    var selected2 = Array.from(select2).filter(e => e.selected);

    for (let el1 of selected1) {
    for (let el2 of selected2) {
    if (el1.text == el2.text) { /* do some... */ }

    /* или так */
    
    if (el1.value == el2.value) { /* do some... */ }
    

    }
    }




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2