回答編集履歴
2
修正
test
CHANGED
@@ -29,6 +29,10 @@
|
|
29
29
|
|
30
30
|
|
31
31
|
#省略なし
|
32
|
+
|
33
|
+
※load処理のためにchangeイベントに変更しました
|
34
|
+
|
35
|
+
|
32
36
|
|
33
37
|
```HTML
|
34
38
|
|
@@ -100,11 +104,11 @@
|
|
100
104
|
|
101
105
|
});
|
102
106
|
|
103
|
-
$('input[name = bbs]').c
|
107
|
+
$('input[name = bbs]').change(function() {
|
104
108
|
|
105
|
-
var myid = $(this).prop('id');
|
109
|
+
var myid = $(this).prop('id');
|
106
110
|
|
107
|
-
var sendlist = {
|
111
|
+
var sendlist = {
|
108
112
|
|
109
113
|
"r1":{"text":"投稿",checkflg:true},
|
110
114
|
|
@@ -112,13 +116,19 @@
|
|
112
116
|
|
113
117
|
"r3":{"text":"削除",checkflg:false},
|
114
118
|
|
115
|
-
};
|
119
|
+
};
|
116
120
|
|
117
|
-
$(
|
121
|
+
if($(this).prop('checked')==true){
|
118
122
|
|
119
|
-
$('
|
123
|
+
$('#send').val(sendlist[myid].text);
|
120
124
|
|
125
|
+
$('[name = "chkid[]"]').prop('disabled',sendlist[myid].checkflg);
|
126
|
+
|
121
|
-
}
|
127
|
+
}
|
128
|
+
|
129
|
+
}).change();
|
130
|
+
|
131
|
+
|
122
132
|
|
123
133
|
});
|
124
134
|
|
@@ -140,7 +150,7 @@
|
|
140
150
|
|
141
151
|
内容:<textarea name="comment" cols="30" rows="3" id="comment"></textarea>
|
142
152
|
|
143
|
-
<input type="radio" name="bbs" id="r1" value="post">投稿
|
153
|
+
<input type="radio" name="bbs" id="r1" value="post" checked>投稿
|
144
154
|
|
145
155
|
<input type="radio" name="bbs" id="r2" value="update">更新
|
146
156
|
|
@@ -162,4 +172,8 @@
|
|
162
172
|
|
163
173
|
<input type="checkbox" name="chkid[]">test3<br>
|
164
174
|
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
165
179
|
```
|
1
追記
test
CHANGED
@@ -25,3 +25,141 @@
|
|
25
25
|
|
26
26
|
|
27
27
|
```
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
#省略なし
|
32
|
+
|
33
|
+
```HTML
|
34
|
+
|
35
|
+
<script src="jquery.js"></script>
|
36
|
+
|
37
|
+
<script>
|
38
|
+
|
39
|
+
$(document).ready(function() {
|
40
|
+
|
41
|
+
$('form').on('submit',function() {//フォーム入力時の条件分岐
|
42
|
+
|
43
|
+
if ($('#r1').prop('checked')) {
|
44
|
+
|
45
|
+
with($('#name')) {
|
46
|
+
|
47
|
+
if (val().length >= 10) {
|
48
|
+
|
49
|
+
window.alert("ERROR1");
|
50
|
+
|
51
|
+
return false;
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
if (val() === "") {
|
56
|
+
|
57
|
+
window.alert("ERROR2");
|
58
|
+
|
59
|
+
return false;
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
with($('#comment')) {
|
66
|
+
|
67
|
+
if (val().length >= 300) {
|
68
|
+
|
69
|
+
window.alert("ERROR3");
|
70
|
+
|
71
|
+
return false;
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
if (val() === "") {
|
76
|
+
|
77
|
+
window.alert("ERROR4");
|
78
|
+
|
79
|
+
return false;
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
if ($('#r2').prop('checked') || $('#r3').prop('checked')) {
|
88
|
+
|
89
|
+
if ($('[name = "chkid[]"]:checked').length == 0) {
|
90
|
+
|
91
|
+
window.alert("ERROR5");
|
92
|
+
|
93
|
+
return false;
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
return true;
|
100
|
+
|
101
|
+
});
|
102
|
+
|
103
|
+
$('input[name = bbs]').click(function() {
|
104
|
+
|
105
|
+
var myid = $(this).prop('id');
|
106
|
+
|
107
|
+
var sendlist = {
|
108
|
+
|
109
|
+
"r1":{"text":"投稿",checkflg:true},
|
110
|
+
|
111
|
+
"r2":{"text":"更新",checkflg:false},
|
112
|
+
|
113
|
+
"r3":{"text":"削除",checkflg:false},
|
114
|
+
|
115
|
+
};
|
116
|
+
|
117
|
+
$('#send').val(sendlist[myid].text);
|
118
|
+
|
119
|
+
$('[name = "chkid[]"]').prop('disabled',sendlist[myid].checkflg);
|
120
|
+
|
121
|
+
});
|
122
|
+
|
123
|
+
});
|
124
|
+
|
125
|
+
</script>
|
126
|
+
|
127
|
+
</head>
|
128
|
+
|
129
|
+
<body>
|
130
|
+
|
131
|
+
<form method="post" action="">
|
132
|
+
|
133
|
+
<table>
|
134
|
+
|
135
|
+
<tr>
|
136
|
+
|
137
|
+
<td>
|
138
|
+
|
139
|
+
名前:<input type="text" name="name" id="name">
|
140
|
+
|
141
|
+
内容:<textarea name="comment" cols="30" rows="3" id="comment"></textarea>
|
142
|
+
|
143
|
+
<input type="radio" name="bbs" id="r1" value="post">投稿
|
144
|
+
|
145
|
+
<input type="radio" name="bbs" id="r2" value="update">更新
|
146
|
+
|
147
|
+
<input type="radio" name="bbs" id="r3" value="delete">削除
|
148
|
+
|
149
|
+
<input type="submit" id="send">
|
150
|
+
|
151
|
+
</td>
|
152
|
+
|
153
|
+
</tr>
|
154
|
+
|
155
|
+
</table>
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
<input type="checkbox" name="chkid[]">test1<br>
|
160
|
+
|
161
|
+
<input type="checkbox" name="chkid[]">test2<br>
|
162
|
+
|
163
|
+
<input type="checkbox" name="chkid[]">test3<br>
|
164
|
+
|
165
|
+
```
|