x
 
1
<!DOCTYPE html>
2
<title>My Example</title>
3
4
<script>
5
// Wait for DOM to load
6
document.addEventListener("DOMContentLoaded", function(event) {
7
8
  // Put the button into a variable
9
  var e = document.getElementById("go");
10
  
11
  // Wait for user to click the button  
12
  e.addEventListener("click", function() {
13
  
14
      // Do the alert box
15
      alert("Thanks... I feel much better now!");
16
      
17
  }, false);
18
  
19
});
20
</script>
21
22
<!-- Replace '{action page}' with your own action page to support non-JavaScript users -->
23
<form name="myForm" action="{action page}">
24
  <input id="go" type="button" value="Click me">
25
</form>