I am currently trying to learn JavaScript and in a particular excercise, I am trying to set the value of a button from a user input, but I keep getting an empty value. Where did I go wrong?
<html>
<head>
<title>JavaScript Variables</title>
<script type="text/javascript">
FIRST_NAME = window.prompt("Enter your first name.");
document.forms[0].username.value = FIRST_NAME;
</script>
</head>
<body>
<form id="myForm">
<input type="button" value="Paul"
onclick="alert('Paul');"/>
<br/><br/>
<input type="button" value="John"
onclick="alert('John');"/>
<br/><br/>
<input type="button" value="George"
onclick="alert('George');"/>
<br/><br/>
<input type="button" value="Ringo"
onclick="alert('Ringo');"/>
<br/><br/>
<input type="button" id="username" name="username" value=''
onclick="alert(FIRST_NAME);"/>
</body>
</html>
The error I get is:
Uncaught TypeError: Cannot read property 'username' of undefined