123

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="uk-container">

  <h1>Disable options in selects that have been selected in another select</h1>
  <p>This allows a user to select a property only once in all selects that reside in a table.</p>
  <p>Disabled options are in red for better visibility.</p>
  <table class="AdminDataList AdminDataTable uk-table uk-table-divider uk-table-justify uk-table-small InputfieldTable">
    <thead>
      <tr>
        <th style="width:50%;"><span class="InputfieldTableHeaderSortable" data-href="./?id=1029&amp;field=raumeigenschaft_allgemein&amp;renderInputfieldAjax=Inputfield_raumeigenschaft_allgemein&amp;raumeigenschaft_allgemein_table_sort=eigenschaft">Eigenschaft</span></th>
        <th style="width:50%;"><span class="InputfieldTableHeaderSortable" data-href="./?id=1029&amp;field=raumeigenschaft_allgemein&amp;renderInputfieldAjax=Inputfield_raumeigenschaft_allgemein&amp;raumeigenschaft_allgemein_table_sort=anmerkung">Anmerkung</span></th>
        <th>&nbsp;</th>
      </tr>
    </thead>
    <tbody class="ui-sortable">
      <tr class="InputfieldTableRowTemplate" style="">
        <td style="width:50%;"><select name="raumeigenschaft_allgemein_0_eigenschaft" class="uk-select" tabindex="82"><option></option><option value="1070">allg. Beleuchtung</option><option value="1062">Barrierefreiheit</option><option value="1066">Beleuchtung</option><option value="1074">Beleuchtungsfarbe</option><option value="1073">Beleuchtungsstärke</option><option value="1071">besondere Beleuchtung</option><option value="1060">Blendschutz</option><option value="1058">Deckenlasten ≥ 5kN/qm</option><option value="1057">Dunkelraum</option><option value="1064">erhöhter Schallschutz außerhalb</option><option value="1063">erhöhter Strahlenschutz innerhalb</option><option value="1069">Kunstlicht</option><option value="1067">Laserschutzklasse</option><option value="1072">Sicherheitsbeleuchtung</option><option value="1065">Sonnenschutz</option><option value="1068">Tageslicht</option><option value="1061">Verdunkelbarkeit</option><option value="1059">Wandlasten</option></select></td>
        <td style="width:50%;"><input type="text" name="raumeigenschaft_allgemein_0_anmerkung" value="" tabindex="83"></td>
        <td class="InputfieldTableActionDelete" style="width: 17px;"><i class="fa fa-trash-o InputfieldTableRowDeleteLink"></i><input class="InputfieldTableRowDelete" type="hidden" name="raumeigenschaft_allgemein_0__delete" value="" tabindex="84"><input class="InputfieldTableRowID" type="hidden" name="raumeigenschaft_allgemein_0__id"
            value="0" tabindex="85"><input class="InputfieldTableRowSort" type="hidden" name="raumeigenschaft_allgemein_0__sort" value="0" tabindex="86"></td>
      </tr>
      <tr>
        <td style="width:50%;"><select name="raumeigenschaft_allgemein_1_eigenschaft" class="uk-select" tabindex="87" data-cip-id="cIPJQ342845647"><option></option><option value="1070">allg. Beleuchtung</option><option value="1062">Barrierefreiheit</option><option value="1066">Beleuchtung</option><option value="1074">Beleuchtungsfarbe</option><option value="1073">Beleuchtungsstärke</option><option value="1071">besondere Beleuchtung</option><option value="1060">Blendschutz</option><option value="1058">Deckenlasten ≥ 5kN/qm</option><option value="1057">Dunkelraum</option><option value="1064">erhöhter Schallschutz außerhalb</option><option value="1063">erhöhter Strahlenschutz innerhalb</option><option value="1069">Kunstlicht</option><option value="1067">Laserschutzklasse</option><option value="1072">Sicherheitsbeleuchtung</option><option value="1065">Sonnenschutz</option><option value="1068">Tageslicht</option><option value="1061">Verdunkelbarkeit</option><option value="1059" selected="selected">Wandlasten</option></select></td>
        <td style="width:50%;"><input type="text" name="raumeigenschaft_allgemein_1_anmerkung" value="" tabindex="88" data-cip-id="cIPJQ342845640"></td>
        <td class="InputfieldTableActionDelete" style="width: 17px;"><i class="fa fa-trash-o InputfieldTableRowDeleteLink"></i><input class="InputfieldTableRowDelete" type="hidden" name="raumeigenschaft_allgemein_1__delete" value="" tabindex="89"><input class="InputfieldTableRowID" type="hidden" name="raumeigenschaft_allgemein_1__id"
            value="11" tabindex="90"><input class="InputfieldTableRowSort" type="hidden" name="raumeigenschaft_allgemein_1__sort" value="1" tabindex="91"></td>
      </tr>
      <tr>
        <td style="width:50%;"><select name="raumeigenschaft_allgemein_2_eigenschaft" class="uk-select" tabindex="92" data-cip-id="cIPJQ342845648"><option></option><option value="1070">allg. Beleuchtung</option><option value="1062" selected="selected">Barrierefreiheit</option><option value="1066">Beleuchtung</option><option value="1074">Beleuchtungsfarbe</option><option value="1073">Beleuchtungsstärke</option><option value="1071">besondere Beleuchtung</option><option value="1060">Blendschutz</option><option value="1058">Deckenlasten ≥ 5kN/qm</option><option value="1057">Dunkelraum</option><option value="1064">erhöhter Schallschutz außerhalb</option><option value="1063">erhöhter Strahlenschutz innerhalb</option><option value="1069">Kunstlicht</option><option value="1067">Laserschutzklasse</option><option value="1072">Sicherheitsbeleuchtung</option><option value="1065">Sonnenschutz</option><option value="1068">Tageslicht</option><option value="1061">Verdunkelbarkeit</option><option value="1059">Wandlasten</option></select></td>
        <td style="width:50%;"><input type="text" name="raumeigenschaft_allgemein_2_anmerkung" value="" tabindex="93" data-cip-id="cIPJQ342845641"></td>
        <td class="InputfieldTableActionDelete" style="width: 17px;"><i class="fa fa-trash-o InputfieldTableRowDeleteLink"></i><input class="InputfieldTableRowDelete" type="hidden" name="raumeigenschaft_allgemein_2__delete" value="" tabindex="94"><input class="InputfieldTableRowID" type="hidden" name="raumeigenschaft_allgemein_2__id"
            value="12" tabindex="95"><input class="InputfieldTableRowSort" type="hidden" name="raumeigenschaft_allgemein_2__sort" value="2" tabindex="96"></td>
      </tr>
      <tr>
        <td style="width:50%;"><select name="raumeigenschaft_allgemein_3_eigenschaft" class="uk-select" tabindex="97" data-cip-id="cIPJQ342845649"><option></option><option value="1070">allg. Beleuchtung</option><option value="1062">Barrierefreiheit</option><option value="1066" selected="selected">Beleuchtung</option><option value="1074">Beleuchtungsfarbe</option><option value="1073">Beleuchtungsstärke</option><option value="1071">besondere Beleuchtung</option><option value="1060">Blendschutz</option><option value="1058">Deckenlasten ≥ 5kN/qm</option><option value="1057">Dunkelraum</option><option value="1064">erhöhter Schallschutz außerhalb</option><option value="1063">erhöhter Strahlenschutz innerhalb</option><option value="1069">Kunstlicht</option><option value="1067">Laserschutzklasse</option><option value="1072">Sicherheitsbeleuchtung</option><option value="1065">Sonnenschutz</option><option value="1068">Tageslicht</option><option value="1061">Verdunkelbarkeit</option><option value="1059">Wandlasten</option></select></td>
        <td style="width:50%;"><input type="text" name="raumeigenschaft_allgemein_3_anmerkung" value="" tabindex="98" data-cip-id="cIPJQ342845642"></td>
        <td class="InputfieldTableActionDelete" style="width: 17px;"><i class="fa fa-trash-o InputfieldTableRowDeleteLink"></i><input class="InputfieldTableRowDelete" type="hidden" name="raumeigenschaft_allgemein_3__delete" value="" tabindex="99"><input class="InputfieldTableRowID" type="hidden" name="raumeigenschaft_allgemein_3__id"
            value="10" tabindex="100"><input class="InputfieldTableRowSort" type="hidden" name="raumeigenschaft_allgemein_3__sort" value="3" tabindex="101"></td>
      </tr>
      <tr>
        <td style="width:50%;"><select name="raumeigenschaft_allgemein_4_eigenschaft" class="uk-select" tabindex="102" data-cip-id="cIPJQ342845650"><option></option><option value="1070" selected="selected">allg. Beleuchtung</option><option value="1062">Barrierefreiheit</option><option value="1066">Beleuchtung</option><option value="1074">Beleuchtungsfarbe</option><option value="1073">Beleuchtungsstärke</option><option value="1071">besondere Beleuchtung</option><option value="1060">Blendschutz</option><option value="1058">Deckenlasten ≥ 5kN/qm</option><option value="1057">Dunkelraum</option><option value="1064">erhöhter Schallschutz außerhalb</option><option value="1063">erhöhter Strahlenschutz innerhalb</option><option value="1069">Kunstlicht</option><option value="1067">Laserschutzklasse</option><option value="1072">Sicherheitsbeleuchtung</option><option value="1065">Sonnenschutz</option><option value="1068">Tageslicht</option><option value="1061">Verdunkelbarkeit</option><option value="1059">Wandlasten</option></select></td>
        <td style="width:50%;"><input type="text" name="raumeigenschaft_allgemein_4_anmerkung" value="1" tabindex="103" data-cip-id="cIPJQ342845643"></td>
        <td class="InputfieldTableActionDelete" style="width: 17px;"><i class="fa fa-trash-o InputfieldTableRowDeleteLink"></i><input class="InputfieldTableRowDelete" type="hidden" name="raumeigenschaft_allgemein_4__delete" value="" tabindex="104"><input class="InputfieldTableRowID" type="hidden" name="raumeigenschaft_allgemein_4__id"
            value="9" tabindex="105"><input class="InputfieldTableRowSort" type="hidden" name="raumeigenschaft_allgemein_4__sort" value="4" tabindex="106"></td>
      </tr>
      <tr>
        <td style="width:50%;"><select name="raumeigenschaft_allgemein_5_eigenschaft" class="uk-select" tabindex="107" data-cip-id="cIPJQ342845651"><option></option><option value="1070">allg. Beleuchtung</option><option value="1062">Barrierefreiheit</option><option value="1066">Beleuchtung</option><option value="1074">Beleuchtungsfarbe</option><option value="1073">Beleuchtungsstärke</option><option value="1071" selected="selected">besondere Beleuchtung</option><option value="1060">Blendschutz</option><option value="1058">Deckenlasten ≥ 5kN/qm</option><option value="1057">Dunkelraum</option><option value="1064">erhöhter Schallschutz außerhalb</option><option value="1063">erhöhter Strahlenschutz innerhalb</option><option value="1069">Kunstlicht</option><option value="1067">Laserschutzklasse</option><option value="1072">Sicherheitsbeleuchtung</option><option value="1065">Sonnenschutz</option><option value="1068">Tageslicht</option><option value="1061">Verdunkelbarkeit</option><option value="1059">Wandlasten</option></select></td>
        <td style="width:50%;"><input type="text" name="raumeigenschaft_allgemein_5_anmerkung" value="" tabindex="108" data-cip-id="cIPJQ342845644"></td>
        <td class="InputfieldTableActionDelete" style="width: 17px;"><i class="fa fa-trash-o InputfieldTableRowDeleteLink"></i><input class="InputfieldTableRowDelete" type="hidden" name="raumeigenschaft_allgemein_5__delete" value="" tabindex="109"><input class="InputfieldTableRowID" type="hidden" name="raumeigenschaft_allgemein_5__id"
            value="13" tabindex="110"><input class="InputfieldTableRowSort" type="hidden" name="raumeigenschaft_allgemein_5__sort" value="5" tabindex="111"></td>
      </tr>
    </tbody>
  </table>
  <h2>Second table</h2>
  <p>This table also has an option "Wandlasten" with the same id="1059", as in the upper table, just to confirm, that this option is not disabled when it is selected in the upper table.</p>
  <table class="AdminDataList AdminDataTable uk-table uk-table-divider uk-table-justify uk-table-small InputfieldTable">
    <thead>
      <tr>
        <th style="width:50%;"><span class="InputfieldTableHeaderSortable" data-href="./?id=1029&amp;field=fussboden&amp;renderInputfieldAjax=Inputfield_fussboden&amp;fussboden_table_sort=eigenschaft">Eigenschaft</span></th>
        <th style="width:50%;"><span class="InputfieldTableHeaderSortable" data-href="./?id=1029&amp;field=fussboden&amp;renderInputfieldAjax=Inputfield_fussboden&amp;fussboden_table_sort=anmerkung">Anmerkung</span></th>
        <th>&nbsp;</th>
      </tr>
    </thead>
    <tbody class="ui-sortable">
      <tr class="InputfieldTableRowTemplate" style="">
        <td style="width:50%;"><select name="fussboden_0_eigenschaft" class="uk-select" tabindex="114"><option></option>
        <option value="1059">Wandlasten</option>
        <option value="1077">ableitfähig</option><option value="1078">antistatisch</option><option value="1079">höhere Rutschhemmung als gem. Unfallverhüt.V</option><option value="1080">schwingungsentkoppelt</option><option value="1076">wischfähig</option></select></td>
        <td style="width:50%;"><input type="text" name="fussboden_0_anmerkung" value="" tabindex="115"></td>
        <td class="InputfieldTableActionDelete" style="width: 17px;"><i class="fa fa-trash-o InputfieldTableRowDeleteLink"></i><input class="InputfieldTableRowDelete" type="hidden" name="fussboden_0__delete" value="" tabindex="116"><input class="InputfieldTableRowID" type="hidden" name="fussboden_0__id" value="0"
            tabindex="117"><input class="InputfieldTableRowSort" type="hidden" name="fussboden_0__sort" value="0" tabindex="118"></td>
      </tr>
      <tr>
        <td style="width:50%;"><select name="fussboden_1_eigenschaft" class="uk-select" tabindex="119" data-cip-id="cIPJQ342845652"><option></option><option value="1059">Wandlasten</option>
        <option value="1077" selected="selected">ableitfähig</option><option value="1078">antistatisch</option><option value="1079">höhere Rutschhemmung als gem. Unfallverhüt.V</option><option value="1080">schwingungsentkoppelt</option><option value="1076">wischfähig</option></select></td>
        <td style="width:50%;"><input type="text" name="fussboden_1_anmerkung" value="" tabindex="120" data-cip-id="cIPJQ342845645"></td>
        <td class="InputfieldTableActionDelete" style="width: 17px;"><i class="fa fa-trash-o InputfieldTableRowDeleteLink"></i><input class="InputfieldTableRowDelete" type="hidden" name="fussboden_1__delete" value="" tabindex="121"><input class="InputfieldTableRowID" type="hidden" name="fussboden_1__id" value="3"
            tabindex="122"><input class="InputfieldTableRowSort" type="hidden" name="fussboden_1__sort" value="1" tabindex="123"></td>
      </tr>
      <tr>
        <td style="width:50%;"><select name="fussboden_2_eigenschaft" class="uk-select" tabindex="124" data-cip-id="cIPJQ342845653"><option></option><option value="1059">Wandlasten</option><option value="1077">ableitfähig</option><option value="1078" selected="selected">antistatisch</option><option value="1079">höhere Rutschhemmung als gem. Unfallverhüt.V</option><option value="1080">schwingungsentkoppelt</option><option value="1076">wischfähig</option></select></td>
        <td style="width:50%;"><input type="text" name="fussboden_2_anmerkung" value="" tabindex="125" data-cip-id="cIPJQ342845646"></td>
        <td class="InputfieldTableActionDelete" style="width: 17px;"><i class="fa fa-trash-o InputfieldTableRowDeleteLink"></i><input class="InputfieldTableRowDelete" type="hidden" name="fussboden_2__delete" value="" tabindex="126"><input class="InputfieldTableRowID" type="hidden" name="fussboden_2__id" value="2"
            tabindex="127"><input class="InputfieldTableRowSort" type="hidden" name="fussboden_2__sort" value="2" tabindex="128"></td>
      </tr>
    </tbody>
  </table>
</div>
            
          
!
            
              option:disabled{
  color: red;
}
            
          
!
            
              function disableUsedOptions($table) {
  $selects = $table.find("select");
  $selects.on("change", function() {
    $selects = $table.find("select");

    console.log("In table:");
    console.log($table);
    console.log("there are " + $selects.length + " selects");
    if ($selects.length <= 1) return;
    let selected = [];
    
    $selects.each(function(index, select) {
      if (select.value !== "") {
        selected.push(select.value);
      }
    });

    console.log("option values, that are being deactivated: " + selected);

    $table.find("option").prop("disabled", false);
    for (var index in selected) {
     $table
                .find('option[value="' + selected[index] + '"]:not(:selected)')
                .prop("disabled", true);
    }
  });
  $selects.trigger("change");
}

$tables = $("table");
$tables.each(function(index) {
  $table = $(this);
  disableUsedOptions($table);
});

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console