summaryrefslogtreecommitdiffstats
path: root/public/regform.js
blob: 98b4b8e634410b3e045319ef57d4af7f89c6a487 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function fetch(url, id) {
  var req = new XMLHttpRequest();
  req.onload = function() {
    var element = document.getElementById(id);
    var node = document.createElement("div");
    node.innerHTML = this.response;
    element.appendChild(node);
  };
  req.open("GET", url);
  req.send();
}

window.onload = function() {
  var num_members = 0;
  var num_songs = 0;

  var add_member_button = document.getElementById('add-member-button');
  var add_song_button = document.getElementById('add-song-button');

  add_member_button.onclick = function() {
    num_members += 1;
    fetch(window.location + '/member/new/' + num_members, 'form-members');
  };

  add_song_button.onclick = function() {
    num_songs += 1;
    fetch(window.location + '/song/new/' + num_songs, 'form-songs');
  };
};