-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.html
92 lines (82 loc) · 3.17 KB
/
search.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
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
<!DOCTYPE html>
<html>
<head>
<title>
Burnout Cars
</title>
<link rel="stylesheet" type="text/css" href="style.css" title="css_style">
</head>
<body>
<div class="search_card">
<h1>Car Inventory</h1>
<a class="button" href="Index.html">Back to Home<a/>
<div style="text-align: center;">
<input type="text" name="search" placeholder="Search by name" id="search">
<button id="btnSearch" value="Search" onclick="search()">Search</button>
</div>
<table id="itemsTable">
<tr>
<th>Seller Name</th>
<th>Address</th>
<th>City</th>
<th>Phone Number</th>
<th>Email Address</th>
<th>Vehicle Make</th>
<th>Vehicle Model</th>
<th>Vehicle Year</th>
<th>JD Power Link</th>
</tr>
</table>
</div>
<style type="text/css">
table {
border-collapse: collapse;
width: 100%;
}
th, td {
text-align: left;
padding: 8px;
}
tr:nth-child(even){background-color: #f2f2f2}
tr:nth-child(odd){background-color: #ffffff}
th {
background-color: #4CAF50;
color: white;
}
</style>
<script>
search();
function search(){
clearTable();
var searchText=document.getElementById('search');
var table = document.getElementById("itemsTable");
var Items=JSON.parse(localStorage.getItem('Items'));
for(var i = 0; i < Items.length; i++) {
var Item = JSON.parse(Items[i]);
if(Item["sellername"].includes(searchText.value,0)){
var row=table.insertRow();
for (var key in Item) {
var cell = row.insertCell();
cell.appendChild(document.createTextNode(Item[key].replace("+"," ")));
}
var Jdcell = row.insertCell();
var JdLink="https://www.jdpower.com/cars/"+Item["vehicleyear"]+"/"+Item["vehiclemake"]+"/"+Item["vehiclemodel"]
var a = document.createElement('a');
var link = document.createTextNode(JdLink);
a.appendChild(link);
a.href =JdLink;
a.target="_blank";
Jdcell.appendChild(a);
}
}
function clearTable(){
var table = document.getElementById("itemsTable");
var rowCount = table.rows.length;
for (var i = rowCount - 1; i > 0; i--) {
table.deleteRow(i);
}
}
}
</script>
</body>
</html>