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! 😊

3rd Sep 2018, 6:06 AM
Avtar_Singh
Avtar_Singh - avatar
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>
3rd Sep 2018, 6:18 AM
Ipang
+ 1
Thanks Ipang ! It worked like charm 😊
3rd Sep 2018, 9:53 AM
Avtar_Singh
Avtar_Singh - avatar
0
You're welcome Avtar_Singh : )
3rd Sep 2018, 10:31 AM
Ipang