質問するログイン新規登録

質問編集履歴

2

不足

2016/09/16 00:58

投稿

zenexvs
zenexvs

スコア12

title CHANGED
File without changes
body CHANGED
File without changes

1

不足分の追記

2016/09/16 00:58

投稿

zenexvs
zenexvs

スコア12

title CHANGED
File without changes
body CHANGED
@@ -80,4 +80,103 @@
80
80
  [{"name":"LessonNameValue","value":"1"},{"name":"LessonRoomNameValue","value":"1"},{"name":"InstructorNameValue","value":""},{"name":"YearValue","value":"2013"},{"name":"MonthValue","value":"3"}]
81
81
  ---
82
82
  どうかよろしくお願いします
83
- 不足があったら申し付けてください。追記します
83
+ 不足があったら申し付けてください。追記します
84
+
85
+ 追記(うまく<form>タグの内容をjsonにできていないみたいなので使っているコードを追記します。不足があったら申し付けてください。追記します)
86
+
87
+ HTML (セレクトボックスの内容はデータベースから拾ってます)
88
+ ```HTML
89
+
90
+ <f:form modelAttribute="DayLessonSearchFormMenu" action="${pageContext.request.contextPath}/day_lesson_search" class="form-inline" method="POST">
91
+ <div class="row">
92
+ <div class="form-group col-lg-2 col-md-2 col-xs-12">
93
+ <label>レッスン名</label>
94
+ </div>
95
+ <div class="form-group col-lg-2 col-md-2 col-xs-12">
96
+ <f:select path="LessonNameValue" items="${lessonNameList}"
97
+ itemLabel="LessonNameLabel" itemValue="LessonNameValue" class="form-control">
98
+ </f:select>
99
+ </div>
100
+ <div class="form-group col-lg-2 col-md-2 col-xs-12">
101
+ <label>教室名</label>
102
+ </div>
103
+ <div class="form-group col-lg-2 col-md-2 col-xs-12">
104
+ <f:select path="LessonRoomNameValue" items="${lessonRoomNameList}"
105
+ itemLabel="LessonRoomNameLabel" itemValue="LessonRoomNameValue" class="form-control">
106
+ </f:select>
107
+ </div>
108
+ <div class="form-group col-lg-2 col-md-4 col-sm-6 col-sm-12">
109
+ <label>担当講師名</label>
110
+ </div>
111
+ <div class="form-group col-lg-2 col-md-4 col-sm-6 col-sm-12">
112
+ <f:select path="InstructorNameValue" items="${instructorNameList}"
113
+ itemLabel="InstructorNameLabel" itemValue="InstructorNameValue" class="form-control">
114
+ </f:select>
115
+ </div>
116
+ </div>
117
+ <div class="row">
118
+ <div class="form-group col-lg-2 col-md-2 col-sm-3 col-xs-12">
119
+ <label>レッスン実施年</label>
120
+ </div>
121
+ <div class="form-group col-lg-2 col-md-2 col-sm-3 col-xs-12">
122
+ <f:select path="YearValue" items="${yearList}"
123
+ itemLabel="YearLabel" itemValue="YearValue" class="form-control">
124
+ </f:select>
125
+ </div>
126
+ <div class="form-group col-lg-2 col-md-2 col-sm-3 col-xs-12">
127
+ <label>レッスン実施月</label>
128
+ </div>
129
+ <div class="form-group col-lg-2 col-md-2 col-sm-3 col-xs-12">
130
+ <f:select path="MonthValue" items="${monthList}"
131
+ itemLabel="MonthLabel" itemValue="MonthValue" class="form-control">
132
+ </f:select>
133
+ </div>
134
+
135
+ </div>
136
+ <div class="row">
137
+ <div class="form-group col-lg-2 col-md-4 col-sm-6 col-sm-12">
138
+ <label>実施時間</label>
139
+ </div>
140
+ <div class="form-group col-lg-6 col-md-4 col-sm-6 col-sm-12">
141
+ <input type="text" class="form-control" placeholder="00:00">~
142
+ <input type="text" class="form-control"placeholder="23:59">
143
+ </div>
144
+ <div class="form-group col-lg-4 col-md-4 col-sm-6 col-sm-12">
145
+ <input type="submit" class="btn btn-default form-control
146
+ search_button" value="検索">
147
+ </div>
148
+ </div>
149
+ </f:form>
150
+
151
+ ```
152
+ 非同期通信と<form>の内容をjsonにして送るjavascriptです
153
+ ```javascript
154
+ $('[value=検索]').click(function() {
155
+ $('form').submit(function(event) {
156
+ event.preventDefault();
157
+ var lessonArr = $('form').serializeArray();
158
+ alert(JSON.stringify(lessonArr));
159
+ $('[value=検索]').attr('disabled', true);
160
+ $.ajax({
161
+
162
+
163
+ type : "GET",
164
+ url : "lesson_search", // リクエストURL
165
+ data : "lessonArr2=" + JSON.stringify(lessonArr),
166
+ datatype: "json",
167
+ success: function(data){
168
+ alert("ok");
169
+ console.log(data);
170
+ $('[value=検索]').attr('disabled', false);
171
+ location.reload();
172
+ },
173
+ error: function(data){
174
+ alert("値はコンソール参照");
175
+ $('[value=検索]').attr('disabled', false);
176
+ location.reload();
177
+ }
178
+
179
+ });
180
+ });
181
+ });
182
+ ```