You cannot put a Javascript variable in the value attribute, whatever is in the value attribute is shown literally as it is in the HTML. If you want to change the value of an input element, it is similar to how you are putting in the <span> except that you should set the .value property instead of .innerHTML.