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
Answer from NDM on Stack OverflowThis 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
Short of constructing your own using DOM methods and Input elements: No.
Videos
In not possible in native browser behavior.
You need use custom library for creating modal element. For example you can use jQuery UI
It is only possible by asking user to provide multiple data with delimeters e.g. input1 input2 input1,input2
and you can describe the format in prompt box message.
At first you don't need an array at all, you just need the total summed up:
var total = 0;
for (var count = 1; count <= 10; count++) {
const number = parseInt(prompt("A number (again):"));
//increase total by the inputted number
total += number;
const average = total / count;
document.body.innerHTML += `The ${count} number is ${number}, the average is ${average} and they differ by ${average - number}`;
}
You may notice that I've used const as much as possible ( cause constant things are better to handle ), as well as a template literal ( the ${..} stuff ) which makes it more readable in my opinion.
var number = new Array(10);
var total; //create a variable for your total
var average; //create a variable for your average
for(var i=0; i<10; i++)
{
var number[i] = prompt("PLEASE ENTER A NUMBER"); //make sure all the
//numbers have their
//own ids which is 'i'
//in this case
total += parseInt(number); //this basically means total = previoustotal
//+ newly parsed number
}
average = total/10; //leave this outside because you want to do the
//calculations at the end
for(var i=0; i < number.length ; i++)
{
document.write("The difference from the average for the number," +
number[i] + "is equal to " + (number[i] - average) + "<br>");
} //this will print out a difference output for all 10 numbers you
//inputted
Not sure how your CSS and HTML was made so i'll just leave the br in there
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"]
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.