How to get the input from the user in JavaScript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to get the input from the user in JavaScript

21st Feb 2017, 8:24 AM
Mallika Balla
Mallika Balla - avatar
2 Answers
+ 3
Prompt() second parameters isn't for title, but for default value ^^ Anyway, this is the easiest way, but the worst also, as it isn't user friendly at all... The right way, is to not be too much lazy, and write at least minimalistic html with an <input type="text">, from where you get the user entry by accessing its 'value' attribute... and eventually an <input type="button"> to call the fuction requiering the user entry ;)
21st Feb 2017, 9:08 AM
visph
visph - avatar
0
var user_name = prompt("Enter your name: ")
21st Feb 2017, 8:30 AM
Abdelaziz Abubaker
Abdelaziz Abubaker - avatar