質問編集履歴

2

ソースコードの記載

2020/05/18 07:05

投稿

pop0910
pop0910

スコア10

test CHANGED
File without changes
test CHANGED
@@ -57,3 +57,285 @@
57
57
  Microsoft Edge 44.18362.449.0
58
58
 
59
59
  Microsoft EdgeHTML 18.18363
60
+
61
+
62
+
63
+
64
+
65
+ ### ソースコード
66
+
67
+ ```HTML
68
+
69
+ <table class="table1">
70
+
71
+ <tr>
72
+
73
+ <td class="formTypeImage">
74
+
75
+ <div class="canvasDiv">
76
+
77
+ <canvas class="imageCanvas" id="imageCanvas"></canvas>
78
+
79
+ </div>
80
+
81
+ </td>
82
+
83
+ <td class="formTypeData">
84
+
85
+ <table class="dataList" id="dataList">
86
+
87
+ <thead class="dataListHead"></thead>
88
+
89
+ <tbody class="dataListBody"></tbody>
90
+
91
+ <!-- 表出力はJSにて実施 -->
92
+
93
+ </table>
94
+
95
+ </td>
96
+
97
+ </tr>
98
+
99
+ </table>
100
+
101
+ ```
102
+
103
+ ```JavaScript
104
+
105
+ // drawFieldTableBody
106
+
107
+ // テーブルボディの表示項目を描画
108
+
109
+
110
+
111
+ function drawFieldTableBody(data, dispList) {
112
+
113
+ var tableBody = document.getElementById("dataList").tBodies.item(0);
114
+
115
+ for(let i = 0; i < data.length; i++){
116
+
117
+ addTableRow(tableBody, data[i], dispList, i);
118
+
119
+ }
120
+
121
+ }
122
+
123
+
124
+
125
+ // addTableRow
126
+
127
+ // テーブルに行を追加
128
+
129
+ function addTableRow(table, rowData, dispList, num){
130
+
131
+ var row = table.insertRow(-1);
132
+
133
+ row.id = OBJ_NAME + num;
134
+
135
+
136
+
137
+ for(let i = 0; i < dispList.length; i++){
138
+
139
+ var cell = row.insertCell(-1);
140
+
141
+ cell.className = dispList[i].className;
142
+
143
+ cell.innerHTML = getHTML(dispList[i], rowData, num);
144
+
145
+ if(dispList[i]['formType'] == 'checkbox'){
146
+
147
+ var checkbox_id = dispList[i]["name"] + "_" + num;
148
+
149
+ document.getElementById(checkbox_id).value = getCheckboxValue(checkbox_id);
150
+
151
+ }
152
+
153
+ }
154
+
155
+ }
156
+
157
+
158
+
159
+ // getHTML
160
+
161
+ // HTMLを生成
162
+
163
+ function getHTML(format, data, num){
164
+
165
+
166
+
167
+ var html = "";
168
+
169
+ html += "<";
170
+
171
+ html += getFormTypeHTML(format["formType"]) + " ";
172
+
173
+ html += "class=" + format["className"].replace("ThTd", "") + " ";
174
+
175
+ if(format['formType'] == 'checkbox'){
176
+
177
+ if(data['checkbox']==1){
178
+
179
+ html += "checked" + " ";
180
+
181
+ }
182
+
183
+ html += "onchange=" + "setCheckboxValue(this)" + " ";
184
+
185
+ html += "name=" + format["name"] + "_" + num + " ";
186
+
187
+ } else {
188
+
189
+ html += "value='" + data[format["name"]] + "'" + " ";
190
+
191
+ html += "name=" + format["name"] + " ";
192
+
193
+ }
194
+
195
+ html += "id=" + format["name"] + "_" + num + " ";
196
+
197
+ if(format['title'] != ''){
198
+
199
+ html += "title=" + format["title"] + " ";
200
+
201
+ }
202
+
203
+ html += "form='register'" + " ";
204
+
205
+ html += "maxlength=" + format["maxlength"] + " ";
206
+
207
+ html += "pattern=" + format["pattern"] + " ";
208
+
209
+ html += "autocomplete='off'" + " ";
210
+
211
+ html += ">";
212
+
213
+
214
+
215
+ // formTypeがselectの場合はoptionの記述を追加
216
+
217
+ html += getSelectHTML(format, data);
218
+
219
+
220
+
221
+ return html;
222
+
223
+ }
224
+
225
+
226
+
227
+ // getFormTypeHTML
228
+
229
+ // フォームのタイプごとのHTMLを生成
230
+
231
+ function getFormTypeHTML(formType){
232
+
233
+ var html = "";
234
+
235
+ switch(formType){
236
+
237
+ case "text":
238
+
239
+ html = "input type='text'";
240
+
241
+ break;
242
+
243
+ case "checkbox":
244
+
245
+ html = "input type='checkbox'";
246
+
247
+ break;
248
+
249
+ case "select":
250
+
251
+ html = "select";
252
+
253
+ break;
254
+
255
+ }
256
+
257
+ return html;
258
+
259
+ }
260
+
261
+
262
+
263
+ // getSelectHTML
264
+
265
+ // プルダウンのHTMLを生成
266
+
267
+ function getSelectHTML(format, data){
268
+
269
+ if(format["formType"] != "select"){
270
+
271
+ return "";
272
+
273
+ }
274
+
275
+
276
+
277
+ var fieldType = data["field_type"];
278
+
279
+
280
+
281
+ var html = "";
282
+
283
+ //活字数字のみ設定
284
+
285
+ if (fieldType == 0 || fieldType == 2) {
286
+
287
+ //change
288
+
289
+ html += "<option value='0' selected>OPTION1</option>";
290
+
291
+ } else {
292
+
293
+ html += "<option value='0' >OPTION1</option>";
294
+
295
+ }
296
+
297
+
298
+
299
+ //活字全般設定
300
+
301
+ if (fieldType == 1 || fieldType == 3) {
302
+
303
+ //change
304
+
305
+ html += "<option value='1' selected>OPTION2</option>";
306
+
307
+ } else {
308
+
309
+ html += "<option value='1' >OPTION2</option>";
310
+
311
+ }
312
+
313
+ html += "</select>";
314
+
315
+
316
+
317
+ return html;
318
+
319
+ }
320
+
321
+
322
+
323
+ // イベントリスナー
324
+
325
+ window.addEventListener('DOMContentLoaded', load, false);
326
+
327
+ document.getElementById('btnDrwaingmode').addEventListener('click', changeMode, false);
328
+
329
+ document.getElementById('btnDelete').addEventListener('click', deleteObj, false);
330
+
331
+ document.getElementById('selectFormTypeImage').addEventListener('change', selectImage, false);
332
+
333
+ document.addEventListener("keydown", keyDownFunc);
334
+
335
+ document.addEventListener("keyup", keyUpFunc);
336
+
337
+ window.addEventListener("wheel", windowMouseWheel, { passive: false });
338
+
339
+ window.addEventListener("resize", windowResizeFunc);
340
+
341
+ ```

1

補足情報が表示できていなかったため修正

2020/05/18 07:05

投稿

pop0910
pop0910

スコア10

test CHANGED
File without changes
test CHANGED
@@ -54,6 +54,6 @@
54
54
 
55
55
  ### 補足情報(FW/ツールのバージョンなど)
56
56
 
57
- Microsoft Edge 44.18362.449.0
57
+ Microsoft Edge 44.18362.449.0
58
58
 
59
- Microsoft EdgeHTML 18.18363
59
+ Microsoft EdgeHTML 18.18363