I know that this should be a really easy question, but I have no idea why a value cannot be assigned to a text field? I've also tried the getElementById by assigning the input an id, but that too doesn't work. I've been struggling with this for the past 3hours. Am I doing something completely wrong?
Javascript is
document.form1.hello.value= "123";
HTML is
<form name="form1" class="" action="index.html" method="post">
<input type="text" name="hello" value="">
</form>
Uncaught TypeError: Cannot read property 'hello' of undefined is the error.
full version is
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript">
document.form1.hello.value= "123";
</script>
</head>
<body>
<form name="form1" class="" action="index.html" method="post">
<input type="text" name="hello" value="">
</form>
</body>
</html>