-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialog.html
54 lines (42 loc) · 1.18 KB
/
dialog.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!-- The HTML <dialog> element represents a dialog box or other interactive component, such as an inspector or window
-->
<!--
<dialog open>
<p>Greetings, one and all!</p>
</dialog>
-->
<dialog id="favDialog">
<form method="dialog">
<section>
<p><label for="favAnimal">Favorite animal:</label>
<select id="favAnimal">
<option></option>
<option>Brine shrimp</option>
<option>Red panda</option>
<option>Spider monkey</option>
</select></p>
</section>
<menu>
<button id="cancel" type="reset">Cancel</button>
<button type="submit">Confirm</button>
</menu>
</form>
</dialog>
<menu>
<button id="updateDetails">Update details</button>
</menu>
<script>
(function() {
var updateButton = document.getElementById('updateDetails');
var cancelButton = document.getElementById('cancel');
var favDialog = document.getElementById('favDialog');
// Update button opens a modal dialog
updateButton.addEventListener('click', function() {
favDialog.showModal();
});
// Form cancel button closes the dialog box
cancelButton.addEventListener('click', function() {
favDialog.close();
});
})();
</script>