I want to run a function that presses a button on site when a number of users changes. I tried doing this with addEventListener and .onchange but first method isn't working at all and second method is running a function right away even when value of users hadn't chanded.
//first method
var ludziki = document.getElementById('online');
ludziki.addEventListener('change',function()
{
document.querySelector('button.gray_inline.button_amount_r').click();
});
//second method
var ludziee = document.getElementById('online');
ludziee.onchange = coraz();
function coraz()
{
document.querySelector('button.gray_inline.button_amount_r').click();
}
219 is the value that im referring to and that value seen on site on which i want to run my script
But what is the online element? Because if was like this could work:
//first method
var ludziki = document.getElementById('online');
ludziki.addEventListener('change',function()
{
document.querySelector('button.gray_inline.button_amount_r').click();
});
<input type='text' id='online'>