Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7968
  • Last Modified:

JavaScript, Alert...Yes No not only OK ???

When the client hit a button on a page I want to ask him
a question. I want to display a messagebox with two buttons,
Yes and No. And I want the client script to be able to
check if the user hit Yes or No. Is this possible? Example
code please?
0
erot
Asked:
erot
  • 3
1 Solution
 
martinagCommented:
confirm("String"). Here's an example:

answer = confirm("Yes or no?");
if (answer == true)
  pressed = "yes";
else
  pressed = "no";
alert('You pressed "' + pressed + '".');

Martin
0
 
erotAuthor Commented:
Great stuff....thanks!

Erot / Norway
0
 
martinagCommented:
Here's an answer for you to grade.

Martin
0
 
martinagCommented:
I see the autograding is working again. Nice. Too bad it has to be used though.

Martin
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now