回答編集履歴
1
sample
test
CHANGED
@@ -7,3 +7,83 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
のどちらかが妥当でしょう
|
10
|
+
|
11
|
+
# sample
|
12
|
+
|
13
|
+
一応テーブルの内容をみて変更する方法をsampleでつけておきます
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
```javascript
|
18
|
+
|
19
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
20
|
+
|
21
|
+
<script>
|
22
|
+
|
23
|
+
$(function(){
|
24
|
+
|
25
|
+
$('input[type=radio][name=gender]').on('change',function(){
|
26
|
+
|
27
|
+
var val=$(this).val();
|
28
|
+
|
29
|
+
if(val!==""){
|
30
|
+
|
31
|
+
$('tbody tr').hide().filter(function(){return $(this).find('td:eq(2)').text()==val}).show();
|
32
|
+
|
33
|
+
}else{
|
34
|
+
|
35
|
+
$('tbody tr').show();
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
});
|
40
|
+
|
41
|
+
});
|
42
|
+
|
43
|
+
</script>
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
<input type="radio" name="gender" value="" checked>選択しない
|
48
|
+
|
49
|
+
<input type="radio" name="gender" value="男">男
|
50
|
+
|
51
|
+
<input type="radio" name="gender" value="女">女
|
52
|
+
|
53
|
+
<?PHP
|
54
|
+
|
55
|
+
$list = array(
|
56
|
+
|
57
|
+
"1"=>array("name"=>'Aさん',"age"=>20,"gender"=>'男'),
|
58
|
+
|
59
|
+
"2"=>array("name"=>'Bさん',"age"=>21,"gender"=>'女'),
|
60
|
+
|
61
|
+
"3"=>array("name"=>'Cさん',"age"=>22,"gender"=>'男'),
|
62
|
+
|
63
|
+
"4"=>array("name"=>'Dさん',"age"=>23,"gender"=>'女'),
|
64
|
+
|
65
|
+
"5"=>array("name"=>'Eさん',"age"=>24,"gender"=>'男'),
|
66
|
+
|
67
|
+
);
|
68
|
+
|
69
|
+
echo "<table><thead><tr><th>名前</th><th>年齢</th><th>性別</th></tr></thead><tbody>";
|
70
|
+
|
71
|
+
foreach($list as $key => $value){
|
72
|
+
|
73
|
+
echo "<tr>";
|
74
|
+
|
75
|
+
echo "<td>".$value["name"]."</td>";
|
76
|
+
|
77
|
+
echo "<td>".$value["age"]."</td>";
|
78
|
+
|
79
|
+
echo "<td>".$value["gender"]."</td>";
|
80
|
+
|
81
|
+
echo "</tr>";
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
echo "</tbody></table>";
|
86
|
+
|
87
|
+
?>
|
88
|
+
|
89
|
+
```
|