html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>INFO2180 - The Avengers</title>
<link rel="stylesheet" href="styles.css" />
<script src="app.js"></script>
</head>
<body>
<div class="heading">
<h1> AVENGERS CHARACTER SEARCH </h1>
</div>
<div class="section">
<div class="container">
<h3>Search by Full Name or Alias</h3>
<div class="searchContainer">
<input id="searchBox" type="text" placeholder="e.g. Captain America or Steve Rogers" name="search">
<button type="button" id="searchBtn" onclick="showSuperHeroes()">Search</button>
</div>
<h2>RESULT</h2>
<hr>
<div id="result"></div>
</div>
</div>
Enter to Rename, Shift+Enter to Preview
css
css
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
body {
margin: 0;
padding: 0;
background-color: rgb(232, 231, 231);
font-family: Arial, Helvetica, sans-serif;
}
.heading{
color: white;
background-color: #5b93e1;
padding: 10px;
}
h1{
text-align: center;
font-size: 39px;
}
h3{
font-size: 16px;
font-weight: 600;
}
.section{
padding: 3% 0% 0% 23% ;
}
#searchBox{
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
var Btn = document.getElementById('searchBtn');
var result = document.getElementById('result');
var heroName= document.getElementById('searchBox');
Btn.onclick = event => {
//fetch('superheroes.php' ,{method: 'get'})
fetch(`superheroes.php?query=${heroName.value}`)
.then(response =>{
return response.text(); // return the response as text
})
.then(data =>{
result.innerHTML= data;
});
}
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run