Putting JavaScript to Work: Using Alerts and Prompts Flashcards

1
Q

alert box

A
  • An alert box is often used if you want to make sure information comes through to the user.
  • When an alert box pops up, the user will have to click “OK” to proceed.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

syntax

A
  • window.alert(“sometext”);
  • The window.alert() method can be written without the window prefix.
  • Example: alert(“I am an alert box!”);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

confirm box

A
  • A confirm box is often used if you want the user to verify or accept something.
  • When a confirm box pops up, the user will have to click either “OK” or “Cancel” to proceed.
  • If the user clicks “OK”, the box returns true. If the user clicks “Cancel”, the box returns false.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

syntax

A
  • window.confirm(“sometext”);
  • The window.confirm() method can be written without the window prefix.
  • Example: if (confirm(“Press a button!”)) {
    txt = “You pressed OK!”;
    } else {
    txt = “You pressed Cancel!”;
    }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the purpose of setting up an Alert?

A
  • Used to alert users of something important
  • It is to provide some textual feedback to the user about something in the form of a pop-up window. In essence it “alerts” the user to something.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What property can you used to restrict a user’s input?

A
  • type

- Correct, using the type property can restrict a user’s input, for example requiring a number value instead of text.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Both an alert and a prompt display a pop-up to the user. How do they differ?

A
  • The alert pop-up only gives you information and the prompt display allows you to type in information
  • An alert simply displays a message to the user, where as the prompt actually asks the user for some sort of input.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly