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

回答編集履歴

1

sample

2019/12/11 09:40

投稿

yambejp
yambejp

スコア117919

answer CHANGED
@@ -1,4 +1,29 @@
1
1
  通常残り人数はサーバー側のDBなどで管理します。
2
2
  参加決定を押すたびに、イベント(?)idに対して、ユーザーidを
3
3
  紐付けていき、最大数までユーザーidを登録していく流れです。
4
- 参加決定は、submitしてもajax(fetch)してもどちらでもよいでしょう
4
+ 参加決定は、submitしてもajax(fetch)してもどちらでもよいでしょう
5
+
6
+ # sample
7
+
8
+ html内で完結しているのであればこんな感じ
9
+ (60回押すのが面倒なのでとりあえず最初からあと5回にしておきます)
10
+ ```javascript
11
+ <script>
12
+ $(function(){
13
+ $('#attend').on('click',function(e){
14
+ e.preventDefault();
15
+ var count=$('#count').text()-1;
16
+ if(count<0) count=0;
17
+ $('#count').text(count);
18
+ });
19
+ });
20
+ </script>
21
+ <div class="top-banner">
22
+ <h1>
23
+ 60名集客まで残り<span id="count">5</span>名
24
+ </h1>
25
+ <form>
26
+ <input type="submit" value="参加決定" name="submit" id="attend">
27
+ </form>
28
+ </div>
29
+ ```