Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to create prompt with two input fields?

Is there any way to create prompt in JavaScript with two input fields ?

I tried that code, but it didn't help me :

var a = prompt("A : ", ""); var b = prompt("B : ", ""); alert(a + "\n" + b); 
like image 994
TN888 Avatar asked Aug 01 '13 12:08

TN888


People also ask

How do I prompt user input?

The prompt() method displays a dialog box that prompts the user for input. The prompt() method returns the input value if the user clicks "OK", otherwise it returns null .

What is prompt and why do we add it in the input command?

Description. x = input( prompt ) displays the text in prompt and waits for the user to input a value and press the Return key. The user can enter expressions, like pi/4 or rand(3) , and can use variables in the workspace. If the user presses the Return key without entering anything, then input returns an empty matrix.


2 Answers

This is not possible with an OS or native browser window popping up. You will have to create a custom overlay dialog.

I would advise using a library like jQuery UI to do this. You can then customize whatever is in the popup.

You can view a demo of the dialog here

like image 74
NDM Avatar answered Sep 21 '22 17:09

NDM


Short of constructing your own using DOM methods and Input elements: No.

like image 25
Quentin Avatar answered Sep 22 '22 17:09

Quentin