回答編集履歴
4
追記
answer
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
逆にcheckAllがチェックされてる場合メール1とメール2のいずれかのチェックが外れたら、checkAllのチェックもはずしたい
|
3
3
|
という意味でしょうか?
|
4
4
|
|
5
|
-
# 追記
|
5
|
+
# 追記1
|
6
6
|
とりあえず上記条件で
|
7
7
|
```javascript
|
8
8
|
$(function(){
|
@@ -22,7 +22,6 @@
|
|
22
22
|
|
23
23
|
```
|
24
24
|
```PHP
|
25
|
-
<?php
|
26
25
|
$data=[
|
27
26
|
array("id_mbr"=>"a0","email_1_mbr"=>"a1","email_2_mbr"=>"a2"),
|
28
27
|
array("id_mbr"=>"b0","email_1_mbr"=>"b1","email_2_mbr"=>"b2"),
|
@@ -37,4 +36,23 @@
|
|
37
36
|
eof;
|
38
37
|
}
|
39
38
|
|
39
|
+
```
|
40
|
+
|
41
|
+
# 追記2
|
42
|
+
ご希望と思われる仕様バージョン
|
43
|
+
```javascript
|
44
|
+
$(function(){
|
45
|
+
$('.checkAll').click(function() {
|
46
|
+
$('.' + this.id).prop('checked', this.checked);
|
47
|
+
});
|
48
|
+
$('input[type=checkbox]').click(function() {
|
49
|
+
if($('#' + $(this).prop('className'))[0]){
|
50
|
+
var flg=false;
|
51
|
+
$('.' + $(this).prop('className')).each(function(){
|
52
|
+
if($(this).prop('checked')){ flg=true};
|
53
|
+
});
|
54
|
+
$('#' + $(this).prop('className')).prop("checked",flg);
|
55
|
+
}
|
56
|
+
});
|
57
|
+
});
|
40
58
|
```
|
3
修正
answer
CHANGED
@@ -12,13 +12,9 @@
|
|
12
12
|
$('input[type=checkbox]').click(function() {
|
13
13
|
if($('#' + $(this).prop('className'))[0]){
|
14
14
|
var flg=true;
|
15
|
-
if(!this.checked){
|
16
|
-
flg=false;
|
17
|
-
}else{
|
18
|
-
|
15
|
+
$('.' + $(this).prop('className')).each(function(){
|
19
|
-
|
16
|
+
if(!$(this).prop('checked')){ flg=false};
|
20
|
-
|
17
|
+
});
|
21
|
-
}
|
22
18
|
$('#' + $(this).prop('className')).prop("checked",flg);
|
23
19
|
}
|
24
20
|
});
|
2
ゴミ
answer
CHANGED
@@ -17,7 +17,6 @@
|
|
17
17
|
}else{
|
18
18
|
$('.' + $(this).prop('className')).each(function(){
|
19
19
|
if(!$(this).prop('checked')){ flg=false};
|
20
|
-
console.log(flg);
|
21
20
|
});
|
22
21
|
}
|
23
22
|
$('#' + $(this).prop('className')).prop("checked",flg);
|
1
変更1
answer
CHANGED
@@ -1,3 +1,45 @@
|
|
1
1
|
これはcheckAllが未チェックの場合、メール1とメール2の両方がチェックされたらcheckAllをチェックし、
|
2
2
|
逆にcheckAllがチェックされてる場合メール1とメール2のいずれかのチェックが外れたら、checkAllのチェックもはずしたい
|
3
|
-
という意味でしょうか?
|
3
|
+
という意味でしょうか?
|
4
|
+
|
5
|
+
# 追記
|
6
|
+
とりあえず上記条件で
|
7
|
+
```javascript
|
8
|
+
$(function(){
|
9
|
+
$('.checkAll').click(function() {
|
10
|
+
$('.' + this.id).prop('checked', this.checked);
|
11
|
+
});
|
12
|
+
$('input[type=checkbox]').click(function() {
|
13
|
+
if($('#' + $(this).prop('className'))[0]){
|
14
|
+
var flg=true;
|
15
|
+
if(!this.checked){
|
16
|
+
flg=false;
|
17
|
+
}else{
|
18
|
+
$('.' + $(this).prop('className')).each(function(){
|
19
|
+
if(!$(this).prop('checked')){ flg=false};
|
20
|
+
console.log(flg);
|
21
|
+
});
|
22
|
+
}
|
23
|
+
$('#' + $(this).prop('className')).prop("checked",flg);
|
24
|
+
}
|
25
|
+
});
|
26
|
+
});
|
27
|
+
|
28
|
+
```
|
29
|
+
```PHP
|
30
|
+
<?php
|
31
|
+
$data=[
|
32
|
+
array("id_mbr"=>"a0","email_1_mbr"=>"a1","email_2_mbr"=>"a2"),
|
33
|
+
array("id_mbr"=>"b0","email_1_mbr"=>"b1","email_2_mbr"=>"b2"),
|
34
|
+
array("id_mbr"=>"c0","email_1_mbr"=>"c1","email_2_mbr"=>"c2"),
|
35
|
+
];
|
36
|
+
foreach ($data as $key => $value) {
|
37
|
+
print <<<eof
|
38
|
+
<input type="checkbox" id="delete_{$value['id_mbr']}" class="checkAll" name="select_delete[]" value="{$value['id_mbr']}" >名前<br>
|
39
|
+
<input type="checkbox" value="{$value["email_1_mbr"]}" class="delete_{$value['id_mbr']}"> メールアドレス1<br>
|
40
|
+
<input type="checkbox" value="{$value["email_2_mbr"]}" class="delete_{$value['id_mbr']}">メールアドレス2<br>
|
41
|
+
|
42
|
+
eof;
|
43
|
+
}
|
44
|
+
|
45
|
+
```
|