【发布时间】:2017-03-24 18:32:54
【问题描述】:
我的要求是:
1 - 如果我从下拉列表中选择任何选项,则它不应显示在除当前选项之外的任何其他下拉列表中。
2 - 如果我将上面选择的选项更改为其他选项,则之前选择的选项应在所有下拉列表中再次显示(添加),并且应从所有其他下拉列表中删除新选项。
HTML
<table class="table table-bordered centeredContent multiSelectFunctionality" id="table">
<tbody>
<tr>
<td>
<button type="button" class="btn btn-plus custom-icon glyphicon glyphicon-plus" onclick="cloneRow();" title="Add Row"></button>
</td>
<td>
<select class="selectedItem form-control" name="selectedItem" id="selectedItem_1">
<option value="entityName">Entity Name</option>
<option value="transmitter_mac">Tag Mac</option>
<option value="tag_number">Tag Number</option>
<option value="sub_category">Sub Category</option>
<option value="name">Department Name</option>
<option value="in_time">In Time</option>
<option value="out_time">Out Time</option>
</select>
</td>
<td>
<input class="form-control searchItem" placeholder="Enter Search item" name="searchItem" />
<!-- <input type="hidden" name="counterValue" id="counterValue" value=""> -->
</td>
</tr>
</tbody>
</table>
JavaScript
function cloneRow() {
counter++;
if (counter >= 7) {
return;
} else {
var a = $("table#table").find("tbody");
var b = a.find("tr:first");
$trLast1 = a.find("tr:last");
$trNew = b.clone();
$trNew.find("button#dltbtn").remove().end();
$trNew.find("td:first").append('<button type="button" class="btn btn-plus custom-icon glyphicon glyphicon-minus" onclick="deleteRow(this);" title="Remove Row"></button>');
$trLast1.after($trNew);
}
}
function deleteRow(a) {
$(a).closest("tr").remove();
counter--;
}
【问题讨论】:
-
我在您的 HTML 中没有看到 ID 为
dltbtn的按钮元素。
标签: javascript jquery html jquery-ui html-select