Last updated on February 14th, 2022 at 01:32 pm

Javascript display prompt to get input from user using javscript

We can use simple javascript here to prompt an input field for your visitors to enter their name for the website. Once they have done that and clicked OK their name will appear in the web page along with the rest of the content. Interesting script, Just copy paste the code below on an html file save it and run it yourself to see the output. Enjoy 🙂

var value = window.prompt("What's your name?,Question From :)");
window.document.write ("Welcome , ");
window.document.write (value);    
<div id="Main_Page">
Rest of the webpage content goes here.


3 thoughts on “How to get user input using javascript”

Leave a Reply

Your email address will not be published. Required fields are marked *