var input = document.getElementById('recharge-input');
var amountTips = document.querySelectorAll("[data-role='amount-tip']")

input.addEventListener('change', inputHasChangedValue, false)

function inputHasChangedValue(e){
    let value = e.target.value;
}

amountTips.forEach(amountTip => {
    amountTip.addEventListener('click', updateInputValue, false);        
});

function updateInputValue(e){
    let selectedValue = e.currentTarget.dataset.value;
	
    //Update input value
    input.value = selectedValue

    //remove all active styles
    amountTips.forEach(amountTip => {
        amountTip.classList.remove('active');        
    });

    //add style to this button
    e.currentTarget.classList.add('active')
}

amountTips[0].click()