Try using document.getElementById
instead of the older, deprecated (not recommended) document.forms
object. So, for example, replace:
document.forms[0].input3.value = 'input 3 value';
with:
document.getElementById('input3').value = 'input 3 value';
Once this is done, give each input
tag a name
attribute. For convenience, give it the same name
as the id
. Form elements work with name
s.
Also, this is unrelated but it's a good idea to have a standards-based doctype to avoid rendering in 'quirks mode' (an old engine mode used for compatibility with old sites). You can do this by sticking this code at the very start of the HTML page:
<!DOCTYPE html>
Addition: since you are using HTML and not XHTML, you shouldn't use the self-close notation for the input
tags (you should remove the slash that is right before the >
).