-
Notifications
You must be signed in to change notification settings - Fork 0
/
Class12.html
35 lines (31 loc) · 1.1 KB
/
Class12.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
<h1>Name Collection Form</h1>
First Name: <input type="text" id="FirstName">
Last Name: <input type="text" id="LastName">
<br><br>
<input type="button" value="Submit Form" onclick="SubmitForm()" >
<input type="button" value="Show Names" onclick="ShowNames()">
<input type="button" value="Reset Form" onclick="ResetForm()">
<br><br>
<div id="Results"></div>
<script>
//This is a comment - https://github.com/MikeYeager/UNM.IT101.Spring2019
var namesArray = [];
var firstNameTextBox = document.getElementById("FirstName");
var lastNameTextBox = document.getElementById("LastName");
var resultsTag = document.getElementById("Results");
function SubmitForm() {
var fullName = firstNameTextBox.value.trim()
+ " "
+ lastNameTextBox.value.trim();
namesArray.push(fullName);
}
function ShowNames() {
resultsTag.innerHTML = namesArray;
}
function ResetForm() {
namesArray = [];
firstNameTextBox.value = "";
lastNameTextBox.value = "";
resultsTag.innerHTML = "";
}
</script>