I'm really new to Javascript and I want to make a scorecounter function for a simple project of mine. I used 2 functions with the same purpose to achieve this but I want to use the same functions for the 2 teams. I'll put the code in here.
var scr1 = document.getElementById('button1');
var scr2 = document.getElementById('button2');
var i = 1;
function buttonClick() {
document.getElementById('inc', 'inc2').value = i++;
}
<div id="scorebox1">
<button id="button1" onclick="buttonClick()">+1 Team 1 </button>
<input type="text" id="inc" value="0"> </input>
</div>
<div id="scorebox2">
<button id="button2" onclick="buttonClick()">+1 Team 2</button>
<input type="text" id="inc2" value="0"></input>
</div>
I'm completely new to functions and parameters and I've searched the terms on google for a long time now but don't really know how to advance. Help would be greatly appreciated.
Cheers and thanks, J.