forked from magrawal-USF/Javascript-JQuery-Charting
-
Notifications
You must be signed in to change notification settings - Fork 197
Expand file tree
/
Copy pathHTMLPage7.html
More file actions
46 lines (32 loc) · 1.16 KB
/
HTMLPage7.html
File metadata and controls
46 lines (32 loc) · 1.16 KB
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
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>JavaScript user input</title>
<script>
function getUserInput() {
var city1 = prompt("What is the first of 4 cities?", "Tampa");
var city2 = prompt("What is the second of 4 cities?", "Tampa");
var city3 = prompt("What is the third of 4 cities?", "Tampa");
var city4 = prompt("What is the fourth of 4 cities?", "Tampa");
var cities = [city1, city2, city3, city4];
var ulElement = document.createElement("ul");
for (var city in cities) {
var cityListItem = document.createElement("li");
var cityListItemtext = document.createTextNode(cities[city]);
cityListItem.appendChild(cityListItemtext);
var listItem = ulElement.appendChild(cityListItem);
if (cities[city] == "Tampa") {
alert("adding your home town!");
}
}
var bodyNode = document.getElementsByTagName("body")[0];
bodyNode.appendChild(ulElement);
}
</script>
</head>
<body>
<h1>JavaScript user input</h1>
<button onclick="getUserInput()">Click me</button>
</body>
</html>