【问题标题】:Filtering dropdownlist based on previous dropdownlist根据先前的下拉列表过滤下拉列表
【发布时间】:2017-08-12 17:53:21
【问题描述】:

请问如何根据用户选择的第一个下拉列表过滤第二个下拉列表?

例如:如果用户在第一个下拉列表中选择 AIA,则第二个下拉列表被禁用。

<tr>
    <td NOWRAP WIDTH="15%"><font FACE="ARIAL" SIZE="2"><strong>Level 1 Organizer</strong></font></td>
    <td NOWRAP >
            <font FACE="ARIAL" SIZE="2"><strong>
        <select name="Organizer" size="1" style="font-family: Arial; font-size: 10pt" onchange="Validate_Report_Level(this.value)">
            <option value="Partnership">Partnership</option>
            <option value="AIA">AIA</option>
            <option value="Agency">Agency</option>
        </select>
            </strong></font>
    </td>
</tr>

【问题讨论】:

  • @Suresh Kommuri 你能帮我看看这个吗?

标签: html filter dropdown disabled-input


【解决方案1】:

试试这个:

html:

<select class="selectItem" name="Organizer" size="1" style="font-family: Arial; font-size: 10pt">
  <option value="Partnership">Partnership</option>
  <option value="AIA">AIA</option>
  <option value="Agency">Agency</option>
</select>

<select class="selectItem" name="Organizer" size="1" style="font-family: Arial; font-size: 10pt">
  <option value="Partnership">Partnership</option>
  <option value="AIA">AIA</option>
  <option value="Agency">Agency</option>
</select>        

jquery:

$('.selectItem').on('change', function () {
  var value = $(this).val();
  $(this).addClass('selected');
  $('.selectItem option:not(.selected)').prop('disabled', false);
  $('.selectItem option[value="' + value + '"]:not(.selected)').prop('disabled', true);
  $(this).removeClass('selected');
});

检查:https://jsfiddle.net/ws6xp69r/

【讨论】:

  • 感谢您的及时回复。我确实从你那里学到了一些东西:)
猜你喜欢
  • 1970-01-01
  • 2012-06-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-03
  • 2014-07-01
  • 2018-04-16
相关资源
最近更新 更多