Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/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
Javascript 启用禁用复选框,但不是全部_Javascript_Html - Fatal编程技术网

Javascript 启用禁用复选框,但不是全部

Javascript 启用禁用复选框,但不是全部,javascript,html,Javascript,Html,我有多个复选框,如果我选择All,我想禁用其他复选框(即Student,Parent,Faculty),但如果我选择Student或其他复选框,则仅禁用All复选框 <input type="checkbox" name="scope[]" value="All">ALL</input> <input type="checkbox" name="scope[]" value="Student">Student</input> <input t

我有多个复选框,如果我选择
All
,我想禁用其他复选框(即
Student
Parent
Faculty
),但如果我选择
Student
或其他复选框,则仅禁用
All
复选框

<input type="checkbox" name="scope[]" value="All">ALL</input>
<input type="checkbox" name="scope[]" value="Student">Student</input>
<input type="checkbox" name="scope[]" value="Parent">Parent</input>
<input type="checkbox" name="scope[]" value="Faculty">Faculty</input>
<input type="checkbox" name="scope[]" value="Others">Others</input>
全部
学生
父母亲
官能
其他

您可以使用相同的名称但不同的ID来禁用复选框

<input type="checkbox" name="scope[]" value="All" id="all">ALL</input>
<input type="checkbox" name="scope[]" value="Student" id="student">Student</input>
<input type="checkbox" name="scope[]" value="Parent" id="Parent">Parent</input>
<input type="checkbox" name="scope[]" value="Faculty" id="Faculty">Faculty</input>
<input type="checkbox" name="scope[]" value="Others" id="others">Others</input>

你需要使用一些JS来做到这一点!问题是?您可以通过由服务器组成标记时设置的自定义属性来控制它们,例如
data ignore=“true”
,但您仍然需要学习如何组成选择器。或者更好的选择是选择Select2多输入。在服务器上更平滑、更容易操作和更容易解析输入。@NhaHoang我不能使用type=“radio”,因为我必须选择多个值的组合,例如Student和ParentHi@CesarWencester我更新了我的ans,并建议您使用一些js来实现这一点。
document.getElementById("others").disabled = true;