Beginner2701
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by Beginner2701
-
-
Hello together,
I am learning JavaScript at the moment and I cannot run a simple code. I do not know if there is a mistake or if I have to install something first!? Quite frustrating since I am at the very beginning.
My code is shown below. It is more or less exactly the code from a lesson I was recently doing, so it should be correct. I just wanted to do a first test to update a webpage by pressing a button. The page should present the username + "signed up" after entering the name and pressing the button. However, if I test it in my firefox it doesn't work. Does also not work in Edge. Is there a mistake in the code? I saved the file under test.html in case that's relevant.
I would appreciate your help!
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>test</title>
</head>
<body><input id="usernameInput" type="text" placeholder="username">
<button onclick="signUp()">Sign up</button>
<p id="message"></p><script type="text/javascript">
function signUp() {
var username = document.getElementsByID("usernameInput").value;
document.getElementsByID("message").innerHTML = username + " signed up";
}</script>
</body>
</html>
Javascript code doesn't run
in JavaScript
Posted
Thanks a lot! Since I was using Atom to write the code that has an autofill function I did not expect to have typos. And thanks for the tip with the console!