0
Get Input from Java Scrip and Add it to my HTML page!
Hi ! A Noob here... I am trying use Prompt to get the page viewerâs name and add it to the return alert and also to my HTML page! I have tried using write.document.innerhtml but canât seem to get it work. Any Help is appreciated! đ
3 Answers
+ 4
<!DOCTYPE html>
<html>
<head>
<title>Sample Page</title>
</head>
<body>
Hello there <span id="username"></span>
<script>
var username = document.getElementById("username");
var user = prompt("Enter your name:");
alert("Welcome " + user);
username.innerHTML = user;
</script>
</body>
</html>
+ 1
Thanks Ipang ! It worked like charm đ
0
You're welcome Avtar_Singh : )