
Brandon T. answered 05/29/19
Web Developer with 4 Years of experience
In order to do this in the most straight forward way possible, I suggest you give your <input> field an id attribute.
You would do this like so:
----- HMTL -----
<input id="myId"> </input>
----- JavaScript ----
document.getElementById("myId").defaultValue = "Set Your Default Value Here";
To explain, there are many ways to select an element in markup using JavaScript. You can select all of the elements of a certain type and then index for the one you need. You can select all of the elements that have a certain css class or data attribute. The most beginner friendly and straight forward way to select an element in markup is to set a unique identifier and select based on this identifier.
I suggest in the future checking out w3schools, they have a lot of tutorials on these topics.