回答編集履歴
4
調整
test
CHANGED
@@ -41,11 +41,12 @@
|
|
41
41
|
e.preventDefault();
|
42
42
|
modal01.showModal();
|
43
43
|
});
|
44
|
-
|
44
|
+
chgDateSub.addEventListener('click',e=>{
|
45
|
-
|
45
|
+
e.preventDefault();
|
46
|
-
if(t.matches("[name=shopping],[name=eating]")){
|
47
|
-
|
46
|
+
let v=document.querySelector('[name=shopping]:checked,[name=eating]:checked')?.value??"";
|
47
|
+
if(v=="お肉") v=m11.value;
|
48
|
+
test.textContent=v;
|
48
|
-
|
49
|
+
modal01.close();
|
49
50
|
});
|
50
51
|
chgDateSub.addEventListener('click',e=>{
|
51
52
|
e.preventDefault();
|
3
chousei
test
CHANGED
@@ -30,6 +30,11 @@
|
|
30
30
|
あとは何をどうしたときに、どこに何をどうしたいのか?をはっきりしてください
|
31
31
|
|
32
32
|
```javascript
|
33
|
+
<style>
|
34
|
+
dialog::backdrop{
|
35
|
+
background-Color:rgba(255,0,0,0.7);
|
36
|
+
}
|
37
|
+
</style>
|
33
38
|
<script>
|
34
39
|
window.addEventListener('DOMContentLoaded', ()=>{
|
35
40
|
document.querySelector('.js-modal-open').addEventListener('click',e=>{
|
@@ -77,7 +82,7 @@
|
|
77
82
|
</p>
|
78
83
|
|
79
84
|
<button type="button" id="closeModal" >閉じる</button>
|
80
|
-
<button type="submit" id="chgDateSub" name="soushin" value="dateup">送信する</button>
|
85
|
+
<button type="submit" id="chgDateSub" name="soushin" value="dateup" disabled>送信する</button>
|
81
86
|
</div>
|
82
87
|
</dialog>
|
83
88
|
```
|
2
調整
test
CHANGED
@@ -23,3 +23,61 @@
|
|
23
23
|
<button type="submit" class="btn btn-primary" id="chgDateSub" name="soushin" value="dateup">送信する</button>
|
24
24
|
</form>
|
25
25
|
```
|
26
|
+
|
27
|
+
# modal処理
|
28
|
+
|
29
|
+
以下がmodalの基本になります
|
30
|
+
あとは何をどうしたときに、どこに何をどうしたいのか?をはっきりしてください
|
31
|
+
|
32
|
+
```javascript
|
33
|
+
<script>
|
34
|
+
window.addEventListener('DOMContentLoaded', ()=>{
|
35
|
+
document.querySelector('.js-modal-open').addEventListener('click',e=>{
|
36
|
+
e.preventDefault();
|
37
|
+
modal01.showModal();
|
38
|
+
});
|
39
|
+
document.addEventListener('change',e=>{
|
40
|
+
const t=e.target;
|
41
|
+
if(t.matches("[name=shopping],[name=eating]")){
|
42
|
+
chgDateSub.disabled=!document.querySelector("[name=shopping]:checked,[name=eating]:checked");
|
43
|
+
}
|
44
|
+
});
|
45
|
+
chgDateSub.addEventListener('click',e=>{
|
46
|
+
e.preventDefault();
|
47
|
+
test.textContent=document.querySelector('[name=shopping]:checked,[name=eating]:checked')?.value??"";
|
48
|
+
modal01.close();
|
49
|
+
});
|
50
|
+
closeModal.addEventListener('click',e=>{
|
51
|
+
e.preventDefault();
|
52
|
+
modal01.close();
|
53
|
+
});
|
54
|
+
|
55
|
+
});
|
56
|
+
</script>
|
57
|
+
<a class="js-modal-open" href="#" data-target="modal01">モーダルウィンドウを開く</a>
|
58
|
+
<p>HELLO</p>
|
59
|
+
<div id="test"></div>
|
60
|
+
<div id="test2"></div>
|
61
|
+
<dialog id="modal01">
|
62
|
+
<div class="c-modal_bg js-modal-close"></div>
|
63
|
+
<div class="c-modal_content _lg">
|
64
|
+
<div class="c-modal_content_inner">
|
65
|
+
<br>予算
|
66
|
+
<input type="text" id="yosan" name="yosan">円
|
67
|
+
<p>
|
68
|
+
<input type="checkbox" name="shopping" id="c1" value="お肉">お肉
|
69
|
+
<select name="meat" id="m11">
|
70
|
+
<option value="牛肉">牛肉</option>
|
71
|
+
<option value="豚肉">豚肉</option>
|
72
|
+
<option value="鶏肉">鶏肉</option>
|
73
|
+
</select>
|
74
|
+
<input type="checkbox" name="shopping" id="c2" value="魚">魚
|
75
|
+
<input type="checkbox" name="shopping" id="c3" value="卵">卵
|
76
|
+
<input type="checkbox" name="eating" id="c4" value="芋">芋
|
77
|
+
</p>
|
78
|
+
|
79
|
+
<button type="button" id="closeModal" >閉じる</button>
|
80
|
+
<button type="submit" id="chgDateSub" name="soushin" value="dateup">送信する</button>
|
81
|
+
</div>
|
82
|
+
</dialog>
|
83
|
+
```
|
1
説明
test
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
name=shoppingかname=eatingの一つでもチェックがあれば送信ボタンが押せるようになる
|
1
|
+
「name=shoppingかname=eatingの一つでもチェックがあれば送信ボタンが押せるようになる」
|
2
|
+
という仕様であれば以下
|
3
|
+
|
2
4
|
```javascript
|
3
5
|
<script>
|
4
6
|
$(function(){
|