ID’s must be equal to id
attribute in HTML. If your HTML contains:
<input id="user">
Which means you need to use same ID in script:
document.getElementById('user').value = "my value";
Make sure the input IDs is not overridden by any other element. If you’re not sure what ID an input is using, you can “Inspect Element” on your browser.
Also, I recommend executing the JavaScript after loading the page.