Javascript examples for DOM HTML Element:Input Text
change form field value with javascript
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {//w w w. j a va2 s. c o m form = document.forms[0]; function up(d,mul) { console.log(d); form[d].value=mul; } up('field1','Hello field 1'); up('field2','Hello field 2'); }); </script> </head> <body> <form method="post" action="doesnt_matter"> <input type="text" name="field1"> <input type="text" name="field2"> </form> </body> </html>