有没有一种方法可以部分限制共享点中的复选框选择?

时间:2019-05-10 13:23:50

标签: checkbox sharepoint

我在复选框列表中有10个选项,在其中我要为前5个选项和第5个选项将0-5个选项限制为一个选项。 例如 我对特定问题的选择是 0 1个 2 3 4 一种 b C d e

用户应该只能为前5个选项(0-4)选择一个复选框,而为其余5个选项(a-b)选择多个

1 个答案:

答案 0 :(得分:0)

我的建议是将0-4和a-b-c-d-e分成不同的列。 0-4可以是仅允许一个选择的单选按钮,而a-b-c-d-e可以是允许多个选择的复选框。

如果arent能够采用这种方法。您可以使用一些骇客的jquery来定位只希望选择一个的前5个。由于它是默认的SharePoint表单,因此您需要根据文本定位

$(document).ready(function() {
   // array of names of 0-4
   var namesArray = ["name1", "name2"];
   // You would need to do something like this
   $("input[type='checkbox']").change(function() {
      // if name of $(this) is contained in array
      // grab the state of the other checkboxes whos names are in array
         // probably using a foreach and ifs
           // if another is checked uncheck it
   });
});

您可能想按照这些原则做些事情。就像我说的有点hacky但可行。我仍然强调将它们分成单独的列。