Here's a working example of what you're trying to do. Hopefully you can use this more modern take on Javascript which uses `const` keyword, the `querySelector` method, and event listeners:
If the HTML is as such:
<span id="waitMessage">initial text</span>
<br>
<input id="aparatusNameButton"...