Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to get user input in javascript

var name = window.prompt("What is your name");
document.write("Hello " + name);
Comment

js get input from user

var name = prompt("Please enter your name", "Harry Potter");
Comment

how to get user input in javascrip

//using npm module
/* 
npm install prompt-sync
# or
yarn add prompt-sync

*/

const prompt = require('prompt-sync')();

const input = prompt('What is your name? ');

console.log(`Oh, so your name is ${input}`);

//* or using readline

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

rl.question('What is your name? ', function (answer) {
  console.log(`Oh, so your name is ${answer}`);
  console.log('Closing the interface');
  rl.close();
});

//* for brouser input

const input1 = prompt();

const input2 = prompt("What's your name?");
alert(`Your name is ${input}`);

const input3 = prompt('Please enter your age:');
alert(`You are ${input} years old`);
Comment

user input in js

var username = prompt("What is your name?");
Comment

how to get a user input in js

Copyvar name = window.prompt("Enter your name: ");
alert("Your name is " + name);
Comment

PREVIOUS NEXT
Code Example
Javascript :: .chartjs-render-monitor 
Javascript :: version control api nodejs best practices 
Javascript :: javascript client side email 
Javascript :: discord.js change role permissions 
Javascript :: ex: Javascript 
Javascript :: This is an example of oligosaccharides: 
Javascript :: javascript make the web browser scroll to the top 
Javascript :: de-encrpting data in javascript 
Javascript :: no unused vars blank underscore javacript 
Javascript :: reactvs y axis range 
Javascript :: javascript loop all depths recursive object 
Javascript :: Add rows to the table dynamically with the use of vue.js 
Javascript :: how to make gamemaker games in javascript 
Javascript :: how to allow the onclick event of a string in javascript 
Javascript :: howler.js play file 
Javascript :: html random 
Javascript :: set value localstorage javascript 
Javascript :: document get all elements by property has white color 
Javascript :: node equivalent of bash exec 
Javascript :: react input mask ref 
Javascript :: set body angle matter.js 
Javascript :: how to create hexadecimal encoded files in javascript 
Javascript :: Content-script overlay for extension 
Javascript :: reinitialise or reset all values in mapping in solidity 
Javascript :: Detect backspace pressed eventlistener 
Javascript :: ist to gmt javascript 
Javascript :: nestjs forRoutes middlewarwe 
Javascript :: javascript unique id generator 
Javascript :: a to z in js using while 
Javascript :: jquery select change price 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =