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

質問編集履歴

2

javaScriptが抜けていたので追記しました。(すみません!)

2019/07/17 08:02

投稿

witoiw
witoiw

スコア17

title CHANGED
File without changes
body CHANGED
@@ -93,7 +93,6 @@
93
93
  </div>
94
94
 
95
95
 
96
-
97
96
  </body>
98
97
  </html>
99
98
 

1

javaScriptが抜けていたので追記しました。(すみません!)

2019/07/17 08:02

投稿

witoiw
witoiw

スコア17

title CHANGED
File without changes
body CHANGED
@@ -16,6 +16,42 @@
16
16
  ### 該当のソースコード
17
17
 
18
18
  ```ここに言語名を入力
19
+ <!doctype html>
20
+ <html>
21
+ <head>
22
+ <meta charset="UTF-8">
23
+ <title>無題/title>
24
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
25
+ <script type="text/javascript">
26
+ jQuery(function($){
27
+ $(function(){
28
+ var items = $("form").find('.rq').length;
29
+ $(".items").html(items);
30
+ var i = 0;
31
+ $(".number").html(items - i);
32
+ $("form").find('.rq').change(function() {
33
+ calc();
34
+ });
35
+ $("form").find('.rq').keyup(function() {
36
+ calc();
37
+ });
38
+ var calc = function() {
39
+ i = 0;
40
+ $("form").find('.rq').each(function() {
41
+ if($(this).val() !== "") {
42
+ i++;
43
+ }
44
+ });
45
+ $(".number").html(items - i);
46
+ };
47
+ });
48
+ });
49
+ </script>
50
+ </head>
51
+
52
+ <body>
53
+
54
+
19
55
  <div class="form_inner">
20
56
  <form method="post" action="">
21
57
  <div class="remaining"><p>残りの入力項目<br><span class="number"></span> / <span class="items"></span></p></div>
@@ -24,12 +60,12 @@
24
60
  <table>
25
61
  <tr>
26
62
  <th>
27
- お問い合わせ種類(複数選択可)<span class="required">必須</span>
63
+ お問い合わせ種類<span class="required">必須</span>
28
64
  </th>
29
65
  <td>
30
- <label><input name="お問い合わせ種類" value="見積り請求" type="checkbox">見積り請求</label><br>
66
+ <label><input name="お問い合わせ種類" value="見積り請求" type="checkbox" class="rq">見積り請求</label><br>
31
- <label><input name="お問い合わせ種類" value="カタログ請求" type="checkbox">カタログ請求</label><br>
67
+ <label><input name="お問い合わせ種類" value="カタログ請求" type="checkbox" class="rq">カタログ請求</label><br>
32
- <label><input name="お問い合わせ種類" value="製品・サービスに関するお問い合せ" type="checkbox">製品・サービスに関するお問い合せ</label>
68
+ <label><input name="お問い合わせ種類" value="製品・サービスに関するお問い合せ" type="checkbox" class="rq">製品・サービスに関するお問い合せ</label>
33
69
  </td>
34
70
  </tr>
35
71
  <tr>
@@ -45,7 +81,7 @@
45
81
  <th>
46
82
  <h2>お問い合わせ内容</h2>
47
83
  </th>
48
- <td class="form_required">
84
+ <td>
49
85
  <textarea type="text" name="" /></textarea>
50
86
  </td>
51
87
  </tr>
@@ -55,4 +91,10 @@
55
91
  </div>
56
92
  </form>
57
93
  </div>
94
+
95
+
96
+
97
+ </body>
98
+ </html>
99
+
58
100
  ```