質問編集履歴

2

前提の文章を変更

2019/09/20 11:33

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
 
4
4
 
5
+ 商品ページ内に2つカゴボタンを設置しています。
6
+
5
- セレクトボックスで何も選択されていない状態で
7
+ どちらのカゴも、セレクトボックスで何も選択されていない状態で
6
-
8
+
7
- カゴボタンを押した時、別ウインドウでアラートを表示させたい。
9
+ カゴボタンを押した時、別ウインドウでアラートを表示させたいです
8
10
 
9
11
  もしくは、ページリロードされないで注意文を表示させたい。
10
12
 

1

ソース変更。smartyタグ等をHTMLに修正。

2019/09/20 11:33

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -50,6 +50,50 @@
50
50
 
51
51
  ```ここに言語名を入力
52
52
 
53
+ <!DOCTYPE HTML>
54
+
55
+ <html lang="ja" class="LC_Page_Products_Detail">
56
+
57
+ <head>
58
+
59
+ <meta charset="UTF-8">
60
+
61
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
62
+
63
+
64
+
65
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=0" />
66
+
67
+ <meta name="format-detection" content="telephone=no">
68
+
69
+ <script src="/user_data/packages/sphone/js/jquery-1.7.min.js"></script>
70
+
71
+ <script src="/user_data/packages/sphone/js/jquery.mobile/jquery.mobile-1.0.1.min.js"></script>
72
+
73
+ <title>商品詳細ページ</title>
74
+
75
+ <script type="text/javascript">//<![CDATA[
76
+
77
+ classCategories = {"__unselected":{"__unselected":{"name":"\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044","product_class_id":"16585","product_type":"1"}},"18":{"#":{"classcategory_id2":"","name":"\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044"},"#0":{"classcategory_id2":"0","name":"","stock_find":true,"price01":"21,240","price02":"14,980","point":"0","product_code":"miy-ar-tv01-db--","product_class_id":"16585","product_type":"1"}},"28":{"#":{"classcategory_id2":"","name":"\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044"},"#0":{"classcategory_id2":"0","name":"","stock_find":true,"price01":"21,240","price02":"14,980","point":"0","product_code":"miy-ar-tv01-lbr--","product_class_id":"16022","product_type":"1"}},"44":{"#":{"classcategory_id2":"","name":"\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044"},"#0":{"classcategory_id2":"0","name":"","stock_find":true,"price01":"21,240","price02":"14,980","point":"0","product_code":"miy-ar-tv01-wh--","product_class_id":"13011","product_type":"1"}}};function lnOnLoad(){fnSetClassCategories(document.form1, ""); }
78
+
79
+ $(function(){
80
+
81
+ lnOnLoad();
82
+
83
+ });
84
+
85
+ //]]></script>
86
+
87
+ </head>
88
+
89
+ <body>
90
+
91
+
92
+
93
+
94
+
95
+ <script src="/js/products.js"></script>
96
+
53
97
  <script>//<![CDATA[
54
98
 
55
99
  // 規格2に選択肢を割り当てる。
@@ -76,394 +120,280 @@
76
120
 
77
121
  <!-- ***************** 通常カゴボタン ***************** -->
78
122
 
123
+
124
+
79
- <form name="form1" id="form1" method="post" action="<!--{$smarty.const.ROOT_URLPATH}-->products/detail.php">
125
+ <form name="form1" id="form1" method="post" action="/products/detail.php">
80
-
126
+
81
- <input type="hidden" name="<!--{$smarty.const.TRANSACTION_ID_NAME}-->" value="<!--{$transactionid}-->" />
127
+ <input type="hidden" name="transactionid" value="6d2cf4aa2aff0db30b9f3a73d9bcd5b040ab9c8c" />
82
128
 
83
129
  <input type="hidden" name="mode" value="cart" />
84
130
 
85
- <input type="hidden" name="product_id" value="<!--{$tpl_product_id}-->" />
131
+ <input type="hidden" name="product_id" value="3709" />
86
-
132
+
87
- <input type="hidden" name="product_class_id" value="<!--{$tpl_product_class_id}-->" id="product_class_id" />
133
+ <input type="hidden" name="product_class_id" value="16585" id="product_class_id" />
88
134
 
89
135
  <input type="hidden" name="favorite_product_id" value="" />
90
136
 
91
- <!--▼買い物かご-->
92
-
93
- <!--{if $tpl_stock_find}-->
94
-
95
-
96
-
97
- <div class="cart_area">
98
-
99
- <!--{if $tpl_classcat_find1}-->
100
-
101
- <dl id="cart_color">
102
-
103
- <!--▼規格1-->
104
-
105
- <dt><!--{$tpl_class_name1|h}--></dt>
106
-
107
- <dd>
108
-
109
- <select name="classcategory_id1"
110
-
111
- style="<!--{$arrErr.classcategory_id1|sfGetErrorColor}-->"
112
-
113
- data-mini="true"><!--デザインデフォルトの場合は class="data-role-none" 付与-->
114
-
115
- <optgroup label="">
116
-
117
- <!--{html_options options=$arrClassCat1 selected=$arrForm.classcategory_id1.value}-->
118
-
119
- </optgroup>
120
-
121
- </select>
122
-
123
- <!--{if $arrErr.classcategory_id1 != ""}-->
124
-
125
- <br /><span class="attention">※ <!--{$tpl_class_name1}-->を入力して下さい。</span>
126
-
127
- <!--{/if}-->
128
-
129
- </dd>
130
-
131
- <!--▲規格1-->
132
-
133
-
134
-
135
- <!--{if $tpl_classcat_find2}-->
136
-
137
- <!--▼規格2-->
138
-
139
- <dt><!--{$tpl_class_name2|h}--></dt>
140
-
141
- <dd>
142
-
143
- <select name="classcategory_id2"
144
-
145
- style="<!--{$arrErr.classcategory_id2|sfGetErrorColor}-->"
146
-
147
- data-mini="true"><!--デザインデフォルの場合は class="data-role-none" 付与-->
148
-
149
- </select>
150
-
151
- <!--{if $arrErr.classcategory_id2 != ""}-->
152
-
153
- <br /><span class="attention">※ <!--{$tpl_class_name2}-->を入力して下さい。</span>
154
-
155
- <!--{/if}-->
156
-
157
- </dd>
158
-
159
- <!--▲規格2-->
160
-
161
- <!--{/if}-->
162
-
163
- </dl>
164
-
165
- <!--{/if}-->
166
-
167
- <dl id="cart_quantity">
168
-
169
- <dt>数量</dt>
170
-
171
- <dd>
172
-
173
- <input type="number" name="quantity" class="quantitybox" value="<!--{$arrForm.quantity.value|default:1|h}-->" max="<!--{$smarty.const.INT_LEN}-->" style="<!--{$arrErr.quantity|sfGetErrorColor}-->" />
174
-
175
- <!--{if $arrErr.quantity != ""}-->
176
-
177
- <br /><span class="attention"><!--{$arrErr.quantity}--></span>
178
-
179
- <!--{/if}-->
180
-
181
- </dd>
182
-
183
- </dl>
184
-
185
- </div>
186
-
187
-
188
-
189
- <div class="cartin_btn">
190
-
191
- <!--★カートに入れる★-->
192
-
193
- <div id="cartbtn_default">
194
-
195
- <a rel="external" href="javascript:;" id="btn-cartin" class="btn cartbtn_default">買い物カゴに入れる</a>
196
-
197
- </div>
198
-
199
- <div class="attention" id="cartbtn_dynamic"></div>
200
-
201
- </div>
202
-
203
- <!--{else}-->
204
-
205
- <div class="cartin_btn" id="btn-cartin">
206
-
207
- <div class="attention">訳ござませんが、只今品切れ中です。</div>
208
-
209
- </div>
137
+
138
+
139
+ <div>
140
+
141
+ <!--▼買い物かご-->
142
+
143
+ <div class="cart_area">
144
+
145
+ <dl id="cart_color">
146
+
147
+ <!--▼規格1-->
148
+
149
+ <dt>カラー</dt>
150
+
151
+ <dd>
152
+
153
+ <select name="classcategory_id1" style="" data-mini="true">
154
+
155
+ <optgroup label="">
156
+
157
+ <option label="選択してください" value="__unselected">選択してください</option>
158
+
159
+ <option label="ダークブラウン" value="18">ダークブラウン</option>
160
+
161
+ <option label="ライトブラウン" value="28">ライトブラウン</option>
162
+
163
+ <option label="ホワイト" value="44">ホワイト</option>
164
+
165
+ </optgroup>
166
+
167
+ </select>
168
+
169
+ </dd>
170
+
171
+ <!--▲規格1-->
172
+
173
+ </dl>
174
+
175
+ <dl id="cart_quantity">
176
+
177
+ <dt>数量</dt>
178
+
179
+ <dd>
180
+
181
+ <input type="number" name="quantity" class="quantitybox" value="1" max="9" style="" />
182
+
183
+ </dd>
184
+
185
+ </dl>
186
+
187
+ </div>
188
+
189
+
190
+
191
+ <div class="cartin_btn">
192
+
193
+ <!--★カーに入れる★-->
194
+
195
+ <div id="cartbtn_default">
196
+
197
+ <a rel="external" href="javascript:;" id="btn-cartin" class="btn cartbtn_default">買い物カゴに入れる</a>
198
+
199
+ </div>
200
+
201
+ <div class="attention" id="cartbtn_dynamic"></div>
202
+
203
+ </div>
204
+
205
+ <!--▲買い物かご-->
206
+
207
+ </div>
208
+
209
+ </form>
210
+
211
+
212
+
213
+
214
+
215
+ <!-- ***************** //通常カゴボタン ***************** -->
216
+
217
+
218
+
219
+
220
+
221
+ <!-- ***************** フローティング化カゴボタン ***************** -->
222
+
223
+ <form name="form2" id="form2" method="post" action="?">
224
+
225
+ <input type="hidden" name="transactionid" value="6d2cf4aa2aff0db30b9f3a73d9bcd5b040ab9c8c" />
226
+
227
+ <input type="hidden" name="mode" value="cart" />
228
+
229
+ <input type="hidden" name="product_id" value="3709" />
230
+
231
+ <input type="hidden" name="product_class_id" value="16585" id="product_class_id" />
232
+
233
+ <input type="hidden" name="favorite_product_id" value="" />
234
+
235
+ <input type="hidden" name="quantity" value="1" />
236
+
237
+ <div id="floatingCartWrap">
238
+
239
+ <!--▼買い物かご-->
240
+
241
+ <div class="cart_area">
242
+
243
+ <dl id="cart_color">
244
+
245
+ <!--▼規格1-->
246
+
247
+ <dd>
248
+
249
+ <select name="classcategory_id1" style="" data-mini="true">
250
+
251
+ <optgroup label="">
252
+
253
+ <option label="選択してください" value="__unselected">選択てください</option>
254
+
255
+ <option label="ダークブラウン" value="18">ダークブラウン</option>
256
+
257
+ <option label="ライトブラウン" value="28">ライトブラウン</option>
258
+
259
+ <option label="ホワイト" value="44">ホワイト</option>
260
+
261
+ </optgroup>
262
+
263
+ </select>
264
+
265
+ </dd>
266
+
267
+ <!--▲規格1-->
268
+
269
+ </dl>
270
+
271
+ </div>
272
+
273
+
274
+
275
+ <div class="cartin_btn">
276
+
277
+ <!--★カートに入れる★-->
278
+
279
+ <div id="cartbtn_default">
280
+
281
+ <a rel="external" href="javascript:void(document.form2.submit())" id="btn-cartin" class="btn cartbtn_default">カゴに入れる</a>
282
+
283
+ </div>
284
+
285
+ <div class="attention" id="cartbtn_dynamic"></div>
286
+
287
+ </div>
288
+
289
+ <!--▲買い物かご-->
290
+
291
+ </div>
292
+
293
+ </form>
294
+
295
+ <!-- ***************** //フローティング化カゴボタン ***************** -->
296
+
297
+
298
+
299
+
300
+
301
+ <!--通常カゴボタン 選択なし時のアラート表示-->
302
+
303
+ <script>
304
+
305
+ $(function(){
306
+
307
+ $('#btn-cartin').click(function(){
308
+
309
+ if ($('select[name=classcategory_id1]').val() == '__unselected') {
310
+
311
+ window.alert('カラーを選択してください。');
312
+
313
+ return;
314
+
315
+ }
316
+
317
+ $('form#form1').submit();
318
+
319
+ });
320
+
321
+ });
322
+
323
+ </script>
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+ </body>
332
+
333
+ </html>
334
+
335
+
336
+
337
+ ```
338
+
339
+
340
+
341
+ ### 試したこと
342
+
343
+
344
+
345
+ 既存アラート部分のスクリプトを複製し、
346
+
347
+ ・#form → #form2
348
+
349
+ ・#btn-cartin → #btn-cartin2
350
+
351
+ ・該当html部分のIDも#btn-cartin → #btn-cartin2
352
+
353
+ としましたがうまくいきませんでした。
354
+
355
+
356
+
357
+ ```ここに言語を入力
358
+
359
+ $('#btn-cartin2').click(function(){
360
+
361
+ <!--{if $tpl_classcat_find1}-->
362
+
363
+ if ($('select[name=classcategory_id1]').val() == '__unselected') {
364
+
365
+ window.alert('<!--{$tpl_class_name1|h}-->を選択してください。');
366
+
367
+ return;
368
+
369
+ }
210
370
 
211
371
  <!--{/if}-->
212
372
 
213
- <!--▲買い物かご-->
373
+
214
-
215
- </form>
374
+
216
-
217
- <!-- ***************** //通常カゴボタン ***************** -->
218
-
219
-
220
-
221
- <!-- ***************** フローティング化カゴボタン ***************** -->
222
-
223
- <form name="form2" id="form2" method="post" action="?">
224
-
225
- <input type="hidden" name="<!--{$smarty.const.TRANSACTION_ID_NAME}-->" value="<!--{$transactionid}-->" />
226
-
227
- <input type="hidden" name="mode" value="cart" />
228
-
229
- <input type="hidden" name="product_id" value="<!--{$tpl_product_id}-->" />
230
-
231
- <input type="hidden" name="product_class_id" value="<!--{$tpl_product_class_id}-->" id="product_class_id" />
232
-
233
- <input type="hidden" name="favorite_product_id" value="" />
234
-
235
- <input type="hidden" name="quantity" value="1" /><!--{* カートフローティング化時に追加/数量1つを自動投入 *}-->
236
-
237
-
238
-
239
- <div id="floatingCartWrap"<!--{if $tpl_stock_find and $tpl_classcat_find1}--><!--{else}--> class="noColor"<!--{/if}-->>
240
-
241
- <!--▼買い物かご-->
242
-
243
- <!--{if $tpl_stock_find}-->
244
-
245
-
246
-
247
- <!--{if $tpl_classcat_find1}-->
248
-
249
- <!--{if $arrErr.classcategory_id1 != ""}-->
250
-
251
- <span class="attention" id="findError">※ <!--{$tpl_class_name1}-->を入力して下さい。</span>
252
-
253
- <!--{/if}-->
254
-
255
-
256
-
257
- <div class="cart_area">
258
-
259
- <dl id="cart_color">
260
-
261
- <!--▼規格1-->
262
-
263
- <!--{* <dt><!--{$tpl_class_name1|h}--></dt> *}-->
264
-
265
- <dd>
266
-
267
- <select name="classcategory_id1"
268
-
269
- style="<!--{$arrErr.classcategory_id1|sfGetErrorColor}-->"
270
-
271
- data-mini="true"><!--デザインデフォルトの場合は class="data-role-none" 付与-->
272
-
273
- <optgroup label="">
274
-
275
- <!--{html_options options=$arrClassCat1 selected=$arrForm.classcategory_id1.value}-->
276
-
277
- </optgroup>
278
-
279
- </select>
280
-
281
- </dd>
282
-
283
- <!--▲規格1-->
284
-
285
-
286
-
287
- <!--{if $tpl_classcat_find2}-->
375
+ <!--{if $tpl_classcat_find2}-->
288
-
376
+
289
- <!--▼規格2-->
377
+ if ($('select[name=classcategory_id2]').val() == '__unselected') {
290
-
378
+
291
- <!--{* <dt><!--{$tpl_class_name2|h}--></dt> *}-->
379
+ window.alert('<!--{$tpl_class_name2|h}-->を選択してください。');
292
-
380
+
293
- <dd>
381
+ return;
294
-
295
- <select name="classcategory_id2"
382
+
296
-
297
- style="<!--{$arrErr.classcategory_id2|sfGetErrorColor}-->"
298
-
299
- data-mini="true"><!--デザインデフォルトの場合は class="data-role-none" 付与-->
300
-
301
- </select>
302
-
303
- <!--{if $arrErr.classcategory_id2 != ""}-->
304
-
305
- <br /><span class="attention">※ <!--{$tpl_class_name2}-->を入力して下さい。</span>
306
-
307
- <!--{/if}-->
308
-
309
- </dd>
310
-
311
- <!--▲規格2-->
312
-
313
- <!--{/if}-->
314
-
315
- </dl>
316
-
317
- </div>
318
-
319
- <!--{/if}-->
320
-
321
-
322
-
323
- <div class="cartin_btn">
324
-
325
- <!--★カートに入れる★-->
326
-
327
- <div id="cartbtn_default">
328
-
329
- <a rel="external" href="javascript:void(document.form2.submit())" id="btn-cartin" class="btn cartbtn_default">カゴに入れる</a>
330
-
331
- </div>
332
-
333
- <div class="attention" id="cartbtn_dynamic"></div>
334
-
335
- </div>
336
-
337
- <!--{else}-->
383
+ }
338
-
339
- <div class="cartin_btn" id="btn-cartin">
340
-
341
- <div class="attention">申し訳ございません。只今品切れ中です。</div>
342
-
343
- </div>
344
384
 
345
385
  <!--{/if}-->
346
386
 
347
- <!--▲買い物かご-->
387
+
348
-
349
- </div>
388
+
350
-
351
- </form>
352
-
353
- <!-- ***************** //フローティング化カゴボタン ***************** -->
354
-
355
-
356
-
357
-
358
-
359
- <!--通常カゴボタン 選択なし時のアラート表示-->
360
-
361
- <script>
362
-
363
- $(function(){
364
-
365
- $('#btn-cartin').click(function(){
366
-
367
- <!--{if $tpl_classcat_find1}-->
368
-
369
- if ($('select[name=classcategory_id1]').val() == '__unselected') {
370
-
371
- window.alert('<!--{$tpl_class_name1|h}-->を選択してください。');
372
-
373
- return;
374
-
375
- }
376
-
377
- <!--{/if}-->
378
-
379
-
380
-
381
- <!--{if $tpl_classcat_find2}-->
382
-
383
- if ($('select[name=classcategory_id2]').val() == '__unselected') {
384
-
385
- window.alert('<!--{$tpl_class_name2|h}-->を選択してください。');
386
-
387
- return;
388
-
389
- }
390
-
391
- <!--{/if}-->
392
-
393
-
394
-
395
- $('form#form1').submit();
389
+ $('form#form2').submit();
396
390
 
397
391
  });
398
392
 
399
- });
400
-
401
- </script>
402
-
403
-
404
-
405
-
406
-
407
393
  ```
408
394
 
409
395
 
410
396
 
411
- ### 試したこと
412
-
413
-
414
-
415
- 既存アラート部分のスクリプトを複製し、
416
-
417
- ・#form → #form2
418
-
419
- ・#btn-cartin → #btn-cartin2
420
-
421
- ・該当html部分のIDも#btn-cartin → #btn-cartin2
422
-
423
- としましたがうまくいきませんでした。
424
-
425
-
426
-
427
- ```ここに言語を入力
428
-
429
- $('#btn-cartin2').click(function(){
430
-
431
- <!--{if $tpl_classcat_find1}-->
432
-
433
- if ($('select[name=classcategory_id1]').val() == '__unselected') {
434
-
435
- window.alert('<!--{$tpl_class_name1|h}-->を選択してください。');
436
-
437
- return;
438
-
439
- }
440
-
441
- <!--{/if}-->
442
-
443
-
444
-
445
- <!--{if $tpl_classcat_find2}-->
446
-
447
- if ($('select[name=classcategory_id2]').val() == '__unselected') {
448
-
449
- window.alert('<!--{$tpl_class_name2|h}-->を選択してください。');
450
-
451
- return;
452
-
453
- }
454
-
455
- <!--{/if}-->
456
-
457
-
458
-
459
- $('form#form2').submit();
460
-
461
- });
462
-
463
- ```
464
-
465
-
466
-
467
397
  ### 補足情報(FW/ツールのバージョンなど)
468
398
 
469
399