What I would like to create is a attendance button. Once the user clicks on the button +1
would be added to the total number of people attending. Is there any way of doing this without refreshing the page? I some how need to connect it to the database to add +1
.
I've heard AJAX could be used and PHP but I have limited knowledge in these languages. Any help please? Here is what I have so far...
$(document).on('click', 'button', function(){
var parente = $(this).prev().text();
var current_val = parseInt($(this).next().text());
current_val++;
$(this).next().text(current_val +' Going '+parente);
// Here you can make ajax request to send the number of people who is going to those events
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html>
<head></head>
<body>
<div class="my_event">
<span>Event 1</span>
<button>I wanna go</button>
<div class="output_event">0</div>
</div>
</body>
</html>
<script src="button.js"></script>