Currently, I am exploring JavaScript examples on w3schools and I have a question. Is there a way to retrieve the text entered by the user while also determining if the user clicked OK or Cancel?
I understand how to check if OK or Cancel was selected:
var r=confirm("Press a button");
if (r==true)
{
alert("You pressed OK!");
}
else
{
alert("You pressed Cancel!");
}
And I know how to obtain data from a text field:
var name=prompt("Please enter your name","Harry Potter");
if (name!=null && name!="")
{
document.write("<p>Hello " + name + "! How are you today?</p>");
}
However, is there a way to capture both of these inputs simultaneously?
Thank you