JavaScript set input value by name | HTML example code

Use getElementsByName to get the elements and Set the value property. If multiple elements then Loop over the array and set each element’s value.

Example JavaScript set input value by name

HTML example code set input value programmatically using JS.

Output:

JavaScript set input value by name HTML

Do comment if you have any doubts and suggestion on this topic.

Note: All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.