I am currently working on on some JavaScript examples from w3schools and I was wondering if there was a way to get the text info entered by the user and at the same time determine if the user clicks OK or cancel.
I know to determine if OK or cancel was pressed by:
var r=confirm("Press a button");
if (r==true)
{
alert("You pressed OK!");
}
else
{
alert("You pressed Cancel!");
}
And to get the 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>");
}
But is there a way to get both of these at the same time?
Thanks
If the user clicks cancel or presses the X then
pis null