1

How to get multiple values in single prompt JavaScript. Doesn't use the input form

var toText = prompt("From", "Lorem");
var fromText = prompt("To", "Ipsum");

3 Answers 3

1

You can get multiple values by separating them with commas and using split method like this:


// Input: Hello, World, Lorem

const promptInput = prompt("Enter comma separated values");
const values = promptInput.split(",")
console.log(values)

// Output: ["Hello", "World", "Lorem"]
Sign up to request clarification or add additional context in comments.

Comments

0

You can get only one input using prompt. You will either have to display multiple prompts or implement a custom dialog window which will basically be a form.

Comments

0

window. prompt() instructs the browser to display a dialog with an optional message prompting the user to input some text, and to wait until the user either submits the text or cancels the dialog.- this is from mdn, you need input

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.