Javascript – Set the value of an input field

formshtmlhtml-inputinputjavascript

How would you set the default value of a form <input> text field in JavaScript?

Best Answer

This is one way of doing it:

document.getElementById("mytext").value = "My value";