ちょっと命名方法がグダグダすぎるような気がしますがこんな感じで
javascript
1<script>
2window.addEventListener('DOMContentLoaded', ()=>{
3 document.querySelector('[id="hogehoge[test]"]').addEventListener('change',()=>{
4 [].filter.call(document.querySelectorAll('[type=checkbox]'),x=>x.id.match(/hoge\d[test]/)).forEach(x=>{
5 x.checked=false;
6 });
7 });
8 [].filter.call(document.querySelectorAll('[type=checkbox]'),x=>x.id.match(/hoge\d[test]/)).forEach(x=>{
9 x.addEventListener('change',()=>{
10 document.querySelector('[id="hogehoge[test]"]').checked=false;
11 });
12 });
13});
14</script>
15<input type="checkbox" name="hoge1[sample]" id="hoge1[sample]" value="1" checked>
16<input type="checkbox" name="hoge2[sample]" id="hoge2[sample]" value="2" checked>
17<input type="checkbox" name="hoge3[sample]" id="hoge3[sample]" value="3" checked>
18<input type="checkbox" name="hoge4[sample]" id="hoge4[sample]" value="4" checked>
19
20<input type="checkbox" name="hoge1[test]" id="hoge1[test]" value="1" checked>
21<input type="checkbox" name="hoge2[test]" id="hoge2[test]" value="2" checked>
22<input type="checkbox" name="hoge3[test]" id="hoge3[test]" value="3" checked>
23<input type="checkbox" name="hoge4[test]" id="hoge4[test]" value="4" checked>
24
25<input type="checkbox" name="hogehoge[test]" id="hogehoge[test]" value="-1">
挙動が違うようなら指摘ください
汎用性
※調整しました
javascript
1<script>
2window.addEventListener('DOMContentLoaded', ()=>{
3 var reg=new RegExp(`hogehoge\[(.+?)\]`);
4 [].filter.call(document.querySelectorAll('[type=checkbox]'),x=>x.id.match(reg)).map(x=>x.id.match(reg)[1]).forEach(id=>{
5 var parent=document.querySelector(`[id="hogehoge[${id}]"]`);
6 var children=[].filter.call(document.querySelectorAll('[type=checkbox]'),x=>x.id.match(new RegExp(`hoge\d\[${id}\]`)));
7 parent.addEventListener('change',()=>{
8 children.forEach(x=>{
9 x.checked=false;
10 });
11 });
12 children.forEach(x=>{
13 x.addEventListener('change',()=>{
14 parent.checked=false;
15 });
16 });
17 });
18});
19</script>
20<input type="checkbox" name="hoge1[sample]" id="hoge1[sample]" value="1" checked>
21<input type="checkbox" name="hoge2[sample]" id="hoge2[sample]" value="2" checked>
22<input type="checkbox" name="hoge3[sample]" id="hoge3[sample]" value="3" checked>
23<input type="checkbox" name="hoge4[sample]" id="hoge4[sample]" value="4" checked>
24<input type="checkbox" name="hogehoge[sample]" id="hogehoge[sample]" value="-1">
25<hr>
26<input type="checkbox" name="hoge1[test]" id="hoge1[test]" value="1" checked>
27<input type="checkbox" name="hoge2[test]" id="hoge2[test]" value="2" checked>
28<input type="checkbox" name="hoge3[test]" id="hoge3[test]" value="3" checked>
29<input type="checkbox" name="hoge4[test]" id="hoge4[test]" value="4" checked>
30<input type="checkbox" name="hogehoge[test]" id="hogehoge[test]" value="-1">
31<hr>
32<input type="checkbox" name="hoge1[fuga]" id="hoge1[fuga]" value="1" checked>
33<input type="checkbox" name="hoge2[fuga]" id="hoge2[fuga]" value="2" checked>
34<input type="checkbox" name="hoge3[fuga]" id="hoge3[fuga]" value="3" checked>
35<input type="checkbox" name="hoge4[fuga]" id="hoge4[fuga]" value="4" checked>
36<input type="checkbox" name="hogehoge[fuga]" id="hogehoge[fuga]" value="-1">