Jquery 动态下拉验证
我有两个下拉列表。 具有值A、B、C、D的下拉列表1 下拉列表2的值为1,2,3,4 如果在下拉列表1中选择了A,并且在下拉列表2中选择了1。这应该是第一次。我使用的是一个动态下拉列表。如果我在下拉列表1中选择了一个,在下拉列表2中选择了一个,同样如此。它不应该允许。请提供我的jQuery验证以防止出现这种情况。提前谢谢 样本: 函数验证cascadingdd(){ 调试器Jquery 动态下拉验证,jquery,Jquery,我有两个下拉列表。 具有值A、B、C、D的下拉列表1 下拉列表2的值为1,2,3,4 如果在下拉列表1中选择了A,并且在下拉列表2中选择了1。这应该是第一次。我使用的是一个动态下拉列表。如果我在下拉列表1中选择了一个,在下拉列表2中选择了一个,同样如此。它不应该允许。请提供我的jQuery验证以防止出现这种情况。提前谢谢 样本: 函数验证cascadingdd(){ 调试器 $('select[id^="ddlApplicableGroup_infrastructure"]').each
$('select[id^="ddlApplicableGroup_infrastructure"]').each(
//start outerloop against each element
function (index, element) {
//find all the items again
$('select[id^="ddlProfileName_infrastructure"]').each(
//start inner loop on each item
function (indexInner, elementInner) {
debugger;
if (index != indexInner) {
//compare the items here as they are not the same index numbers so are different elements
//there are different ways to compare, but you could use jquery again for this
//and use the element and elementInner to access each of them.
if ($(element).val() == $(elementInner).val())
alert("2 dd have the same value:" + element.id + ":" + elementInner.id);
}
}
);
}
);
}