diff options
Diffstat (limited to 'public')
-rw-r--r-- | public/regform.js | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/public/regform.js b/public/regform.js index 42bbd58..a74d087 100644 --- a/public/regform.js +++ b/public/regform.js @@ -1,19 +1,29 @@ -$(function() { +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; - $('#add-member-button').click(function(event) { + 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; - $.get('member/new/' + num_members, function(data) { - $('#form-members').append(data); - }); - }); + fetch('member/new/' + num_members, 'form-members'); + }; - $('#add-song-button').click(function(event) { + add_song_button.onclick = function() { num_songs += 1; - $.get('song/new/' + num_songs, function(data) { - $('#form-songs').append(data); - }); - }); - -}); + fetch('song/new/' + num_songs, 'form-songs'); + }; +}; |