Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 动态下拉验证_Jquery - Fatal编程技术网

Jquery 动态下拉验证

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

我有两个下拉列表。 具有值A、B、C、D的下拉列表1 下拉列表2的值为1,2,3,4

如果在下拉列表1中选择了A,并且在下拉列表2中选择了1。这应该是第一次。我使用的是一个动态下拉列表。如果我在下拉列表1中选择了一个,在下拉列表2中选择了一个,同样如此。它不应该允许。请提供我的jQuery验证以防止出现这种情况。提前谢谢

样本: 函数验证cascadingdd(){ 调试器

    $('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);
                }
            }
         );
      }
    );


}