You are now checking only at beginning.
You should use onchange event listener instead.
Or a easier way, add your function as click callback to a button.
I have chosen the easy way with onclick attribute and onchange attribute in HTML tags.
A better way is to use addEventListener so that we can add more event listeners and also remove unnecessary event listeners later.
That will be after your DOM lessons.