-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhw6part2.html
More file actions
118 lines (99 loc) · 4.15 KB
/
hw6part2.html
File metadata and controls
118 lines (99 loc) · 4.15 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!DOCTYPE html>
<html lang="en">
<head>
<!--Kristian Reyes 11/10/2020 -->
<title>CNIT 133 Homework 6</title>
<meta charset="utf-8">
<meta name="description" content="homework 6 for CCSF CNIT 133">
<meta name="keywords" content="HTML, CSS, Javascript, CCSF, Student">
<meta name="author" content="Kristian Reyes">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<!--bootstrap -->
<script>
function charFinder()
{
var count=0;
var key=document.getElementById("searchchar").value.charAt( 0 );
var key=key.toUpperCase();
var stringToSearch=document.getElementById("userinput").value;
var stringToSearch=stringToSearch.toUpperCase();
for (i=0; i < stringToSearch.length; i++)
{
if (stringToSearch.charAt(i) == key)
count++;
}
if ( count == 0 )
sendData();
else{
document.getElementById("results").value=count +
" occurrence(s) of " + key + " found";
}
function sendData()
{
// html for new window
var myText = "<html>\n";
myText += "<head>\n";
myText += "<title>Popup Window</title>\n";
myText += "</head>\n";
myText += "<body>\n";
myText += "<div style='margin:0 auto;'>\n";
myText += "<p><strong>Search character " + key + " not found in text string!</p>\n";
myText += "<input type='button' value='Close Window' onclick='window.close()'>\n";
myText += "</div>\n";
myText += "</body>\n";
myText += "</html>";
// open new windoww
var newWindow = window.open("", "new_window",
"top=100,left=100,width=300,height=100");
// focuses on new window
newWindow.focus();
// html sent to new window
newWindow.document.write(myText);
// closes the write action
newWindow.document.close();
}}
</script>
</head>
<body>
<main class="grid">
<header class="grid-area grid-area-1">
<h2> Homework 6 - Part 2 </h2>
</header>
<nav class="grid-area grid-area-2">
<ul>
<li>
<a href="homework6.html" title="CNIT 133 - HW 6 ">
Return to CNIT 133 Homework 6 - Objects
</a>
</li>
</ul>
</nav>
<section class="grid-area grid-area-3">
<h2> Part 2</h2>
<p> Please input several lines of text below: </p>
<textarea name="userinput" rows="8" id="userinput" ></textarea>
<br>
<br>
<form name="myForm">
Enter a search character: <br>
<input type="text" size="30" id="searchchar">
<input type="button" value="Submit" onclick="charFinder()">
<input type="reset" value="Reset" onClick="location.reload();">
</form>
<br>
<br>
<textarea name="results" id="results" rows="3" readonly></textarea>
</section>
<footer class="grid-area grid-area-4">
<p>
© 2020 Kristian Reyes
</p>
</footer>
</main>
</body>
</html>